支持流式 Chat Completions 输出 usage chunk#21
Merged
Merged
Conversation
ghost
reviewed
May 25, 2026
ghost
left a comment
There was a problem hiding this comment.
AI PR Review
Decision: comment
Confidence: 0.86
Summary
整体实现与 PR 描述一致:为流式 Chat Completions 增加了 stream_options.include_usage=true 时的 usage 输出,并覆盖了文本、Grok Console、Grok app-chat 三条流式路径;测试也验证了 usage: null 普通 chunk、choices: [] 最终 usage chunk 以及 token 统计聚合逻辑。未发现明确阻塞性问题。
Findings
No specific findings were returned.
Recent Comment Summary
实现方向正确、测试覆盖到位,当前未发现需要阻塞的缺陷。建议后续可补充一个“messages 为空时 completion/reasoning token 是否应继续统计”的行为说明或测试,以明确边界语义。
This was referenced May 25, 2026
Contributor
Author
|
补充说明:本 PR 已指向 |
Owner
|
感谢贡献,PR #21 已完成审查并 merge 到 dev。 合并信息: 合并前处理:
验证结果:
安全与兼容性审查未发现新增依赖、脚本、CI/Docker 变更、敏感信息泄露或可疑外联/执行逻辑。PR 页面上旧的 enforce failure 仍是此前 fork PR label cleanup 权限问题,不是本次合并后的代码阻断。 |
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.
改动
stream_options.include_usage=true的 Chat Completions 流式 usage 输出。choices: []且包含usage的 chunk。usage: null。prompt_tokens、completion_tokens和total_tokens。验证
python -m py_compile services/protocol/openai_v1_chat_complete.py test/test_grok_provider.pypython -m unittest test.test_grok_provider.GrokProviderTests.test_streaming_grok_chat_completion_returns_openai_chunks test.test_grok_provider.GrokProviderTests.test_streaming_grok_console_completion_emits_reasoning_content test.test_grok_provider.GrokProviderTests.test_streaming_grok_console_completion_includes_usage_when_requested test.test_grok_provider.GrokProviderTests.test_streaming_grok_app_chat_completion_emits_reasoning_content test.test_grok_provider.GrokProviderTests.test_streaming_grok_app_chat_completion_includes_usage_when_requested test.test_grok_provider.GrokProviderTests.test_streaming_text_completion_includes_usage_when_requested关联 #19