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:
claude-code-best
2026-04-16 15:31:18 +08:00
parent 90027279e6
commit cfab161e28
4 changed files with 132 additions and 2 deletions

View File

@@ -77,6 +77,7 @@ export function recordLLMObservation(
startTime?: Date
endTime?: Date
completionStartTime?: Date
tools?: unknown
},
): void {
if (!rootSpan || !isLangfuseEnabled()) return
@@ -90,7 +91,9 @@ export function recordLLMObservation(
genName,
{
model: params.model,
input: params.input,
input: params.tools
? { messages: params.input, tools: params.tools }
: params.input,
metadata: {
provider: params.provider,
model: params.model,