mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-10-26 01:54:36 +08:00
Capture per-request token usage from each provider's stream and expose it as an OpenAI-shaped usage field on a trailing chunk, so the agent can show an accurate context-usage count instead of a char-based estimate. - OpenAI-compatible bots (deepseek/doubao/mimo/moonshot/modelscope): request stream_options.include_usage and forward the trailing usage chunk. - minimax: capture the usage it already emits on a trailing chunk. - claude: read input_tokens (message_start) + output_tokens (message_delta) and emit a trailing usage chunk. - gemini: map usageMetadata to the OpenAI usage shape. - dashscope: map input_tokens/output_tokens onto each chunk. Purely additive; content/tool-call parsing paths are unchanged, and unknown stream_options are ignored by providers that do not support them. Co-authored-by: cowagent <cow@cowagent.ai>