mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-20 23:35:51 +00:00
feat(langfuse): LLM generation 记录工具定义
将 Anthropic 格式的工具定义转换为 Langfuse 兼容的 OpenAI 格式,
并在 generation 的 input 中以 { messages, tools } 结构传入,
以便在 Langfuse UI 中查看完整的工具定义信息。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,21 @@ export function convertMessagesToLangfuse(
|
||||
return result
|
||||
}
|
||||
|
||||
/** Convert Anthropic-style tool schemas to Langfuse-compatible OpenAI-style tool format */
|
||||
export function convertToolsToLangfuse(tools: unknown[]): unknown[] {
|
||||
return tools.map(tool => {
|
||||
const t = tool as Record<string, unknown>
|
||||
return {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: t.name,
|
||||
description: t.description,
|
||||
parameters: t.input_schema ?? t.parameters ?? {},
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** Convert AssistantMessage[] (newMessages) → Langfuse output format (last assistant turn) */
|
||||
export function convertOutputToLangfuse(
|
||||
messages: AssistantMessage[],
|
||||
|
||||
Reference in New Issue
Block a user