generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 253
Open
Description
Describe the bug
使用 Langsmith 监控 Graph,当 Gemini ChatModel 进行非流式调用(Non-streaming Generate)时,Langsmith Trace 详情页中的 Token Usage 统计数据显示为 0(Input, Output, Total 均为 0),无法正确反映实际的 Token 消耗。
To Reproduce
Steps to reproduce the behavior:
- 配置 components/model/gemini 作为 ChatModel,配置 callbacks/langsmith。
- 发起一次非流式的 Generate 调用。
- 在 Langsmith 控制台点击该 LLM 节点的 Trace。
- 查看 Metadata 标签页下的 Usage 信息。
- 现象:显示 "0 tokens"。
Expected behavior
Langsmith 应正确显示 Gemini API 返回的 Token 消耗数据(Prompt Tokens, Completion Tokens, Total Tokens)。
Version:
github.com/cloudwego/eino-ext/callbacks/langsmith (latest)
github.com/cloudwego/eino-ext/components/model/gemini (latest)
Environment:
GOVERSION='go1.25.3'
Additional context
我尝试在本地修复。在 Langsmith OnEnd 回调方法中,检查输出是否为 *model.CallbackOutput,如果是,则将其中的 TokenUsage 提取出来,并按照 Langsmith 的格式 (input_tokens, output_tokens, total_tokens) 写入到 extra.metadata.usage_metadata 字段中。问题似乎得到了解决。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels