feat: add stream_include_usage option for OpenAI-compatible providers#94
Open
hitsmaxft wants to merge 2 commits intoSaladDay:mainfrom
Open
feat: add stream_include_usage option for OpenAI-compatible providers#94hitsmaxft wants to merge 2 commits intoSaladDay:mainfrom
hitsmaxft wants to merge 2 commits intoSaladDay:mainfrom
Conversation
- Inject stream_options.include_usage=true into streaming requests when
stream_include_usage is set in the provider settings config
- Defer message_delta emission to [DONE] so the trailing usage chunk
(choices:[], usage:{...}) is captured before building the event
- Cache trailing usage chunk to surface real input/output token counts
in message_delta instead of null
- Update README and README_ZH with configuration instructions
Author
|
在dashscope API上测试过 个人而言,此选项可在所有openai_chat提供者上默认启用,openai/dashscope/azure_openai均支持此选项。 |
…de_usage() - Add Provider::stream_include_usage() method that reads explicit config and falls back to api_format-based defaults (true for openai-compatible) - Replace all scattered reads in proxy provider_router, claude adapter, and stream_check request builders with the centralized method - OpenAI chat / responses compatible providers default to true; anthropic native defaults to false
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.
修复 [feature request] OpenAI 协议 provider 需要提供选项开启流式返回 token usage #93
open ai端点输出格式为:
``
data: stop_reason=stop
data: token usage
[DONE]
``
因此转换过程应缓冲
stop reason事件,待完成事件到达时结合令牌使用量一并发送