feat: add token usage - #459
Merged
Merged
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
主要改动:
输出上,单条 LLM 结果会有 usage;summary.json 会有 token_usage。统计只使用服务商返回的 usage,不做本地 tokenizer 估算;provider 不返回时为空。
当 LLM 服务返回 token usage 时,Dingo 会在对应的
EvalDetail中写入usage字段,并在summary.json中按字段组合和 evaluator 汇总到token_usage。该统计来自模型服务商返回的usage,不会本地估算;如果兼容 API 不返回 usage,则对应字段为空。单条结果示例:
{ "metric": "LLMTextQualityV5", "status": false, "label": ["QUALITY_GOOD"], "reason": ["pass"], "usage": { "prompt_tokens": 812, "completion_tokens": 96, "total_tokens": 908, "reasoning_tokens": null, "cached_tokens": null, "model": "gpt-4o-mini", "provider": "openai", "calls": 1, "source": "provider" } }汇总结果示例:
{ "token_usage": { "content": { "LLMTextQualityV5": { "prompt_tokens": 81200, "completion_tokens": 9600, "total_tokens": 90800, "reasoning_tokens": 0, "cached_tokens": 12000, "calls": 100, "records": 100, "models": {"gpt-4o-mini": 100}, "providers": {"openai": 100}, "sources": {"provider": 100} } } } }