排查"rust→PPT"task(flash,34 轮)发现累计 tokens_in 69.9 万里 88.6% 是缓存 命中,但 _fallback_chat_cost_cny 把命中段也按 input 全价算,记账虚高 2-3x。 - capabilities: 加 cache_hit_cny_per_mtoken(deepseek flash 0.1 / pro 0.2; 0=不区分按全价兜底,绝不少记) - usage: 成本公式拆三段「命中×缓存价 + (input−命中)×input价 + output×output价」; loop 把 cache_hit_tokens + 缓存单价透传进 record_chat_usage - web: 不加 DB 列。app.py 加 _usage_aggregates(单查询 GROUP BY usage_events, 复用列表 msg_counts 批量范式,无 N+1)on-the-fly 算每 task 真实成本 + 缓存命中, _task_dict 带出;dev.html 列表行显 ¥、顶栏 formatTaskUsage 显「tok·缓存命中%·¥」 - scripts: backfill_chat_cost_cache_discount.py 按 units 已存 token 重算历史 cost_cny(只改成本列,默认 dry-run,--apply 落库) 折价只对新 chat 事件即时生效;历史走 backfill 脚本(部署后跑)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| deepseek_v4.yaml | ||
| glm.yaml | ||
| local.yaml | ||