Skip to content

修复 DeepSeek 计费价格与新会话花费重置#978

Merged
esengine merged 1 commit into
esengine:mainfrom
OHCJ099:fix/deepseek-cny-billing
May 16, 2026
Merged

修复 DeepSeek 计费价格与新会话花费重置#978
esengine merged 1 commit into
esengine:mainfrom
OHCJ099:fix/deepseek-cny-billing

Conversation

@OHCJ099
Copy link
Copy Markdown
Contributor

@OHCJ099 OHCJ099 commented May 15, 2026

概要

  • 将 DeepSeek V4 的计费常量更新为官方当前公布的 USD 单价
  • 当 API 没有返回 prompt_cache_miss_tokens 时,用 prompt_tokens - prompt_cache_hit_tokens 兜底,避免漏算未命中输入
  • /new 新建对话时同步重置 loop 统计和状态栏花费,避免新会话继承旧的“本会话已花费”

原因

当前官方价格页显示:

  • deepseek-v4-flash: cache hit input $0.0028 / 1M tokens,cache miss input $0.14 / 1M tokens,output $0.28 / 1M tokens
  • deepseek-v4-pro: 当前优惠期 cache hit input $0.003625 / 1M tokens,cache miss input $0.435 / 1M tokens,output $0.87 / 1M tokens

旧表中 flash 兼容模型的 cache hit input 被高估了 10 倍,v4-pro 也还是旧的更高价格。另外 /new 只清聊天记录,没有清 SessionStats 和 UI 状态栏计数,所以新对话里“本会话已花费”可能继续沿用旧累计。

参考:https://api-docs.deepseek.com/quick_start/pricing/

验证

  • npm run lint
  • npm run typecheck
  • npm run build
  • npm test -- --run
  • push 前自动 npm run verify

@OHCJ099 OHCJ099 force-pushed the fix/deepseek-cny-billing branch from 652dce3 to c5a69f0 Compare May 15, 2026 18:46
@OHCJ099 OHCJ099 changed the title fix(billing): align DeepSeek pricing and reset session spend 修复 DeepSeek 计费价格与新会话花费重置 May 15, 2026
@ADX15xs
Copy link
Copy Markdown

ADX15xs commented May 15, 2026

你好呀,我的 PR #981 跟你 PR 在 src/telemetry/stats.ts 的官方价格上有冲突,我是按 中文版 价格换算以符合 USD_TO_CNY = 7.2 的转换逻辑,你的是直接引用 英文版 官网价格,看 @esengine 怎么想,这俩主要差在pro上,flash没差;

另外 tests/telemetry.test.ts 测试文件的 flashCost * 倍数也有点区别,你的 3 倍是合理的;

问题不大都挺好处理的,你的合完我再 rebase 解决下冲突就行。

@ADX15xs ADX15xs mentioned this pull request May 15, 2026
4 tasks
@esengine esengine merged commit 159c500 into esengine:main May 16, 2026
5 checks passed
@OHCJ099
Copy link
Copy Markdown
Contributor Author

OHCJ099 commented May 16, 2026

你好,感谢说明。我这边主要是按英文版官方 USD 价格表修复计费显示问题。看到 #978 已经合并了,后续 #981 rebase 时按 main 保留新 constants 就好,辛苦啦。

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.

3 participants