Skip to content

fix(pricing): resolve DeepSeek V4.1 Flash pricing and ordering - #7632

Open
Lingbou wants to merge 2 commits into
farion1231:mainfrom
Lingbou:fix/7512-deepseek-v4-1-pricing
Open

Lingbou wants to merge 2 commits into
farion1231:mainfrom
Lingbou:fix/7512-deepseek-v4-1-pricing

Conversation

@Lingbou

@Lingbou Lingbou commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Seed deepseek-v4.1-flash so provider-prefixed dotted model IDs such as deepseek-ai/DeepSeek-V4.1-Flash resolve to the DeepSeek V4.1 Flash price instead of being billed at zero.
  • Sort model pricing rows by non-empty displayName using case-insensitive ordering, with model_id as the fallback for empty names and the stable tie-breaker for duplicate display names.
  • Add end-to-end logger and zero-cost backfill regressions covering the original provider-prefixed ID, the recommended name, and legacy aliases.

Verification

  • cargo test --lib deepseek_v41 -- --nocapture — 4 passed
  • cargo test --lib model_pricing -- --nocapture — 19 passed
  • cargo fmt --all -- --check — passed
  • cargo clippy --lib --tests — passed with one pre-existing unrelated warning in transform_codex_chat.rs

Closes #7512

@Lingbou
Lingbou requested a review from farion1231 as a code owner September 23, 2026 10:31
@github-actions github-actions Bot added backend Backend (Rust/Tauri) proxy Related to proxy/API forwarding labels Sep 23, 2026
@farion1231

Copy link
Copy Markdown
Owner

GPT-6 Astra 自动代码审查

审查提交:8fd7b0126c22e80b84f7e00a16690c78690fedb5
Base:f2537fdf6b709082b52886d52ce6914bae690699

由 Codex 定时任务使用 GPT-6 Astra 子 agent 审查,并经主 agent 复核。

本次审查未发现可确认的问题。

验证与范围

已对精确 BASE...HEAD 的全部五个变更文件进行独立审查,并覆盖关键生产调用链与新增测试。生产变更仅新增 DeepSeek V4.1 Flash 定价种子及调整列表排序;补种保留已有价格,模型清洗可命中新条目,列表排序不改变计费查询。5 项隔离离线测试全部通过,未发现具有足够证据、由本次改动新增且可发布的真实 bug、安全缺陷或行为回归。coverage_complete 表示 diff 与关键上下文已完整读取,不表示运行了完整测试套件。

  • 读取完整 bundle:cat /tmp/cc-switch-astra-review-20260924.g96peR/prs/7632.json;确认 PR fix(pricing): resolve DeepSeek V4.1 Flash pricing and ordering #7632、精确 base/head SHA、独立 review_workspace;comments、reviews、inline 均为空,无已有实质意见需要去重。
  • 在独立 worktree 执行 git rev-parse HEAD,结果为 8fd7b01;git merge-base f2537fd 8fd7b01 返回所指定 base SHA。
  • 完整读取 git diff f2537fd...8fd7b01 --,覆盖全部 5 个文件、203 行增加和 4 行删除;读取补种、定价覆盖、模型归一化、精确及前缀匹配、成本计算、logger、历史回填、启动及归档调用方、会话用量查价调用方和前端列表消费上下文。
  • 执行 cargo test --offline --manifest-path /tmp/cc-switch-astra-review-20260924.g96peR/validation-7632/Cargo.toml -- --nocapture:5 项测试全部通过,0 失败。测试使用本地已有 rusqlite 0.31.0 与 log 缓存,不访问真实数据库或服务;产物仅位于 validation-7632。
  • 最小 Rust 测试在构建时直接抽取精确 HEAD 的 seed_model_pricing、find_model_pricing_row、归一化及查询辅助函数、query_model_pricing 和原 PR 排序测试;同时用 git show 读取精确 BASE 的 seed_model_pricing。验证 BASE 对原始 dotted ID 查价为空,HEAD 补种后正确命中,记录数只增加 1,重复补种幂等,已有价格及 dotted ID 自定义价格保持不变。
  • 其余通过用例覆盖 9 种别名、大小写及日期后缀输入的四个价格字段,V4 Pro 保持原价,未定义的 V4.1 Pro 不误命中,以及空名称回退、重复显示名、仅大小写不同 ID 的确定排序和返回字段不变。
  • 通过 web.open 只读核对 DeepSeek 官方定价页 https://api-docs.deepseek.com/quick_start/pricing/:DeepSeek-V4.1-Flash 的官方高峰输入、输出、缓存命中价格为每百万 token 0.3、1.2、0.006 美元,与新增种子一致;官方推荐名及两个 legacy 名的模型归属也与代码使用方式一致。
  • git diff --check f2537fd...8fd7b01 返回 0;审查前后 git --no-optional-locks status --short 均无输出,独立审查 worktree 未修改。

未验证或受限范围:

  • 遵守最小验证要求,未构建完整 Tauri 应用,未运行仓库完整 cargo test、clippy 或前端交互测试。最小 Rust 测试使用简化的错误类型及定价 DTO,不能替代完整应用集成测试。
  • 新增 logger 与零成本 backfill 端到端测试及其实际调用链已静态审查,但未在完整应用依赖环境中执行;不能把 PR 正文声称的测试结果当作本次实际执行结果。
  • 官方定价核对支持第一方高峰档基准,不证明所有第三方聚合商的实际售价均相同;本次未使用真实凭据或调用第三方计费服务。

本评论仅针对以上提交的代码审查结果,不构成合并批准。

@Lingbou

Lingbou commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

@farion1231

1 similar comment
@Lingbou

Lingbou commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

@farion1231

@Lingbou

Lingbou commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@farion1231 已同步变基至最新 v4.0.4 主线。修复 DeepSeek V4.1 Flash 定价表匹配与排序异常,分支无冲突且 CI 全绿,方便时麻烦审阅一下,谢谢!

@Lingbou

Lingbou commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@farion1231 这边已经顺手跟最新的 main 对齐过了,依然可以 clean merge,等空下来看下哈,不着急~

leoxstar added a commit to leoxstar/cc-switch that referenced this pull request Oct 14, 2026
leoxstar added a commit to leoxstar/cc-switch that referenced this pull request Oct 14, 2026
…_calculation signature

PR farion1231#7632 的测试按旧签名写(含已移除的 cost_multiplier 参数,缺 cache_creation_1h_tokens),
merge-tree 干净但编译不过;补齐字段、去掉多余参数,行为与断言不变。
@farion1231

Copy link
Copy Markdown
Owner

感谢修复和补的测试!

排序这部分在当前 main 上依然有效:定价列表现在还是按 display_name 直接排序(usage.rs#L209-L213),小写开头的名字(比如 issue 里的 deepseek-ai/DeepSeek-V4.1-Flash)仍会排到所有大写名字后面。

另外有两处变化需要处理一下:

  • deepseek-v4.1-flash 的定价种子 main 已经在 8163460 里加了(同样是 0.3 / 1.2 / 0.006),schema.rs 这里会冲突,这一段可以直接去掉。
  • 合进最新 main 后,logger.rs 新加的测试编译不过:TokenUsage 多了 cache_creation_1h_tokens 字段,log_with_calculation 也去掉了成本倍率那个参数(测试里的 Decimal::from(1))。

麻烦 rebase 到最新 main 后我们再看,谢谢!

Seed `deepseek-v4.1-flash` so provider-prefixed dotted IDs such as `deepseek-ai/DeepSeek-V4.1-Flash` resolve to the V4.1 Flash price instead of silently costing zero. Add regressions for dotted IDs, provider prefixes, mixed case, and the existing legacy aliases.

Refs farion1231#7512

Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
Sort non-empty display names case-insensitively with model_id fallback and tie-breaking so custom provider-prefixed rows stay in their expected group. Add logger-level regressions for the raw V4.1 ID, recommended name, and legacy aliases.

Refs farion1231#7512

Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
@Lingbou
Lingbou force-pushed the fix/7512-deepseek-v4-1-pricing branch from 8fd7b01 to 2f92b55 Compare October 22, 2026 10:48
@Lingbou

Lingbou commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@farion1231 感谢指导!

已完成变基并处理好冲突与测试适配:

  1. 去重种子:去掉了 schema.rs 中重复添加的 deepseek-v4.1-flash 种子(主线已包含),解除了合并冲突。保留了对大小写不敏感与 model_id 回退的定价列表排序优化(usage.rs)。
  2. 测试签名适配:在 src-tauri/src/proxy/usage/logger.rs 中对齐了最新 TokenUsage 字段(补齐 cache_creation_1h_tokens: 0)并移除了已废弃的成本倍率入参。
  3. 全部分支已 rebase 到最新 main,并通过 cargo fmt --check、cargo clippy 及 5 项定价相关单元测试,欢迎复看!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend (Rust/Tauri) proxy Related to proxy/API forwarding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

第三方模型deepseek-ai/DeepSeek-V4.1-Flash价格显示异常,排序异常

2 participants