feat(pricing): 新增 override_file 价格目录覆盖补丁

新增 pricing.override_file 配置(默认关闭):稀疏补丁文件按 JSON 字段
浅合并覆盖目录/回退数据,作为最高优先级数据源,用于本地自定义官方
目录条目(如显式 long_context_input_token_threshold=0 关闭某模型阶梯)
而无需自建价格镜像:

- applyPricingOverrides 挂在 parsePricingData 解析入口,只修补已存在
  条目(补丁字段覆盖同名字段,值为 null 删除字段);目录、回退与灾备
  路径都经该入口,覆盖语义三处一致
- mergeOverrideOnlyModels 在回退合并后把目录/回退都没有的模型作为
  独立条目并入(复用主解析路径,须自带价格字段通过有效性过滤);
  不在主解析时抢先建条目,避免纯补丁挡住回退完整条目、其余分项价
  静默变 0
- 最终未生效的条目(模型名拼错、纯补丁落在不存在的模型上)打 WARN
  哨兵;override 文件缺失/损坏仅跳过合并,不影响目录加载
- 生效时机为重启或下次目录下载,与 fallback_file 一致;fallback_file
  只补缺失模型的语义不变
This commit is contained in:
feeeei
2026-09-01 01:26:55 +08:00
parent 530fb20f25
commit 593fc93659
4 changed files with 334 additions and 0 deletions
+8
View File
@@ -1066,6 +1066,14 @@ pricing:
# Fallback pricing file
# 备用定价文件
fallback_file: "./resources/model-pricing/model_prices_and_context_window.json"
# Override patch file (optional, highest priority): entries are shallow-merged
# field-by-field over catalog/fallback data; a null field value removes that field.
# Model names must match catalog keys exactly. Edits take effect on restart or
# the next catalog download.
# 覆盖补丁文件(可选,优先级最高):条目按字段浅合并覆盖目录/回退数据,
# 字段值为 null 表示删除该字段。模型名须与目录键完全一致。
# 修改后重启或下次目录下载时生效。
# override_file: "./data/model_pricing_overrides.json"
# Update interval in hours
# 更新间隔(小时)
update_interval_hours: 24