Skip to content

fix(xai): 保留流式用量 token 明细 - #146

Merged
woncc merged 1 commit into
mainfrom
cursor/upstream-issue-134-651d5a213-20261105
Nov 5, 2026
Merged

woncc merged 1 commit into
mainfrom
cursor/upstream-issue-134-651d5a213-20261105

Conversation

@woncc

@woncc woncc commented Nov 4, 2026

Copy link
Copy Markdown

🔗 关联任务 / Related Issue

Closes #134

上游:QuantumNous/new-api@651d5a2(QuantumNous#6420)。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)

📝 变更描述 / 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

  • 人工确认: 待维护者审阅并确认
  • 非重复提交: 已查询 fork 同分支及上游 SHA 对应的开放 PR,无重复
  • 功能范围: 仅 xAI 流式用量修复
  • 非透传: 修改标准流式转换路径
  • 范围聚焦: 无无关代码
  • 本地验证: 上述定向测试及差异检查通过
  • 安全合规: 未添加凭据或改变认证流程

@woncc
woncc merged commit c786ced into main Nov 5, 2026
@woncc
woncc deleted the cursor/upstream-issue-134-651d5a213-20261105 branch December 2, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[上游/现在能解] 651d5a213 xAI 流式用量保留 token 明细

1 participant