Repository navigation
fix(xai): 保留流式用量 token 明细 - #146
Merged
Merged
Conversation
Port upstream 651d5a2 (QuantumNous#6420). Closes #134
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.
🔗 关联任务 / Related Issue
Closes #134
上游:QuantumNous/new-api@651d5a2(QuantumNous#6420)。
🚀 变更类型 / Type of change
📝 变更描述 / Description
同步上游两行修复,保留 xAI 流式返回用量中的输入缓存和输出 token 明细,使后续计费能够读取缓存数量。保留 fork 的完成 token 差值计算及非流式行为,仅修改 xAI text.go 和 text_test.go。
本改动及测试由 Codex AI 辅助完成。已核对 git 身份 woncc 与历史主要提交者一致;仍明确披露 AI 参与。此 PR 待维护者人工审阅,不代签人工确认。
📸 运行证明 / Proof of Work
命令:
GOMAXPROCS=2 GOWORK=off go test -p=2 ./relay/channel/xai/ -count=1。同一回归测试在原实现失败:返回缓存数量 0(期望 60),推理数量 0(期望 15);应用修复后包测试通过(0.052s)。测试同时覆盖明细缺省、完成 token 仍为 total−prompt,以及客户端 SSE 保留明细。
git diff --check通过。未执行真实 xAI 请求、完整结算链或全仓测试;无数据库行为或独立模块改动。
✅ 提交前检查项 / Checklist