feat(compare): 比价记录 LLM token 成本落库与展示(按当时价冻结) #133

Merged
guke merged 1 commits from feat/llm-token-cost into main 2026-07-13 17:46:12 +08:00
Member
  • comparison_record 加 llm_cost_yuan(元/float)+ llm_price_snapshot(JSON)两列
  • _backfill_llm_calls 回填时按 app_config 当时单价逐模型算成本、冻结成本+快照到记录
  • app_config 新增 llm_token_price 配置(per_model + default 兜底,运营在系统配置页可改)
  • services/llm_cost.py:compute_llm_cost 纯函数(按 model 分桶、error/无 usage 跳过、
    脏价格当 unpriced 不抛异常以免连累 token 回填)+ get_llm_prices reader
  • admin schema 暴露成本:列表项带 llm_cost_yuan,详情另带价格快照
  • tests/test_llm_cost.py(10 测试);scripts/seed_mock_llm_cost.py(mock seeder)

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

- comparison_record 加 llm_cost_yuan(元/float)+ llm_price_snapshot(JSON)两列 - _backfill_llm_calls 回填时按 app_config 当时单价逐模型算成本、冻结成本+快照到记录 - app_config 新增 llm_token_price 配置(per_model + default 兜底,运营在系统配置页可改) - services/llm_cost.py:compute_llm_cost 纯函数(按 model 分桶、error/无 usage 跳过、 脏价格当 unpriced 不抛异常以免连累 token 回填)+ get_llm_prices reader - admin schema 暴露成本:列表项带 llm_cost_yuan,详情另带价格快照 - tests/test_llm_cost.py(10 测试);scripts/seed_mock_llm_cost.py(mock seeder) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
guke added 1 commit 2026-07-13 15:09:00 +08:00
- comparison_record 加 llm_cost_yuan(元/float)+ llm_price_snapshot(JSON)两列
- _backfill_llm_calls 回填时按 app_config 当时单价逐模型算成本、冻结成本+快照到记录
- app_config 新增 llm_token_price 配置(per_model + default 兜底,运营在系统配置页可改)
- services/llm_cost.py:compute_llm_cost 纯函数(按 model 分桶、error/无 usage 跳过、
  脏价格当 unpriced 不抛异常以免连累 token 回填)+ get_llm_prices reader
- admin schema 暴露成本:列表项带 llm_cost_yuan,详情另带价格快照
- tests/test_llm_cost.py(10 测试);scripts/seed_mock_llm_cost.py(mock seeder)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
guke merged commit 5c6840dd71 into main 2026-07-13 17:46:12 +08:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: WonderableAI/shaguabijia-app-server#133