161 Commits

Author SHA1 Message Date
3ad50beda8 refactor: 清理冗余空字段
- 空 filters/filter_labels/formula 不返回
- min_amount=0 不返回
- 返回只保留有实际值的字段
2026-06-05 18:49:51 +08:00
66b4744def fix: tiered只展示价格不同的条目,过滤冗余
- 当tiered价格等于主unit_price时不展示
- 去掉重复的model=qwen3.7-max:6.0等冗余行
2026-06-05 18:47:50 +08:00
38ff69ca55 refactor: 精简pricing_display, tiered只保留有意义filter
- 过滤内部参数: value_mode, xxx_tokens 区间条件不展示
- tiered 只保留 model 等有意义的 filter key
- display_text 去掉冗余 prefix
2026-06-05 18:34:27 +08:00
3eefe1a67f fix: pricing_display 不乘unit_val + 添加可读display_text字段
1. 新格式 unit_prices 已是展示价,不再乘以 unit_val
2. tiered 定价同步修复
3. 返回增加 display_text 字段,格式如官网价格表
2026-06-05 18:26:30 +08:00
2706815dee fix: use DictObject for config_data to support dot notation in derived fields 2026-06-05 16:07:35 +08:00
022bab8314 feat: add derived field support for nested usage data
- Support dot notation in derived expressions (e.g., prompt_tokens_details.cached_tokens)
- Auto-flatten nested dict keys to underscore format for eval
- Calculate uncached_prompt_tokens and cached_tokens from raw usage data
- Test case: qwen3.7-max pricing with derived fields

Test result:
- uncached_prompt_tokens = prompt_tokens - cached_tokens = 1075
- Total cost: 0.007116 元 ✓
2026-06-05 15:04:47 +08:00
df1fa2cfe0 fix: 百万单位定价展示乘以单位值 + 生产混合格式走formula路径
1. get_pricing_display: unit_price 乘以 unit_val 得到人类可读展示价
   (如 4e-06 * 1000000 = 4.0 元/百万tokens)
2. get_pricing_display: unit_values 默认值补全百万/秒/千等映射
3. is_new_format 判断增加类型检查: price_factors为list或unit_prices为dict
   时走旧格式formula路径,避免生产数据TypeError
4. filters区间定价展示价同步乘以unit_val
2026-06-05 14:33:36 +08:00
e2d46f4074 fix: add fallback unit_values in get_pricing_display 2026-06-05 14:32:27 +08:00
da07250049 feat: update unit_values and get_pricing_display for new format
- unit_values: only include units actually used in pricing_data
- get_pricing_display: support new format (price_factors + unit_prices + unit)
- Add fallback unit values for common units
2026-06-05 14:06:58 +08:00
7200454c46 feat: support new pricing format (price_factors + unit_prices)
- get_pricing_from_ymalstr: 支持新格式和旧公式格式
  * 新格式: price_factors + unit_prices + unit 自动计算
  * 旧格式: formula eval 计算(向后兼容)
  * filters: 支持区间定价,多个区间只要匹配一个即可
  * min_amount: 支持最低消费
  * flat: 支持固定费用

- convert_pricing_to_new_design.py: 转换脚本
  * 自动转换 35 条定价记录
  * 无需人工审核

测试通过:
- 多因子计费 (prompt_tokens + completion_tokens)
- 按时长计费 (duration)
- 固定费用 (flat)
- 最低消费 (min_amount)
- 区间定价 (filters)
- 旧公式兼容
2026-06-05 14:00:24 +08:00
977be0d39c feat: add pricing display API for customer-facing pricing data
- generate_formula_from_factors(): auto-generate formula from price_factors array
- get_pricing_display(ppid): return structured human-readable pricing data
- wwwroot/api/get_pricing_display.dspy: API endpoint for frontend consumption
- Supports price_factors display layer (label, unit_price, unit_label)
- Backward compatible: old YAML without pricing_type/price_factors works
- Registered via load_pricing() with ServerEnv
2026-06-04 12:13:55 +08:00
5d4e008ec8 fix: guard hot_reload binding with None check
hasattr only checks attribute existence, but event_dispatcher
can exist as None when running standalone (backend_accounting.py).
Use getattr with None check instead.
2026-06-02 17:36:38 +08:00
ba69fb84d1 debug: add hot_reload handler logging 2026-06-01 22:53:09 +08:00
b7ca795127 cleanup: remove dead module-level get_pricing_program and duplicate assignment 2026-06-01 18:57:50 +08:00
52dd91c6ee chore: remove __pycache__, add to gitignore 2026-06-01 18:10:39 +08:00
7b9d3d2ba0 refactor: bind hot_reload event via EventDispatcher, add on_hot_reload to PricingProgram 2026-06-01 18:10:30 +08:00
8159c79d55 feat: respect module_cache config for pricing cache 2026-05-29 17:59:06 +08:00
5813749a98 bugfix 2026-05-27 18:17:44 +08:00
b981d07f40 fix: refresh pricing cache for timing id events 2026-05-19 01:12:55 +08:00
c85b9527c3 bugfix 2026-05-18 16:02:14 +08:00
1677d18704 bugfix 2026-05-16 16:55:58 +08:00
eebe7c2733 bugfix 2026-05-16 16:53:01 +08:00
168ce230c4 bugfix 2026-05-16 16:50:01 +08:00
7095d8dca2 bugfix 2026-05-16 16:40:09 +08:00
1f1faaa085 bugfix 2026-05-16 16:38:44 +08:00
7468bcd781 bugfix 2026-05-16 16:36:41 +08:00
4f40be10dc bugfix 2026-05-16 16:32:47 +08:00
a264e72a24 bugfix 2026-05-16 16:19:22 +08:00
19f03c82c3 bugfix 2026-05-16 16:13:18 +08:00
f78c6f6494 bugfix 2026-05-14 13:41:41 +08:00
37ad188a26 bugfix 2026-05-14 13:34:29 +08:00
4667c49372 bugfix 2026-05-14 13:16:37 +08:00
8643e22a50 bugfix 2026-05-14 13:14:35 +08:00
e7381291e8 bugfix 2026-05-14 13:12:05 +08:00
896c87c4f0 bugfix 2026-05-14 13:10:13 +08:00
c2a273d07f bugfix 2026-05-07 16:42:45 +08:00
80126a9058 bugfix 2026-04-28 12:01:04 +08:00
45aa425980 bugfix 2026-04-24 22:11:07 +08:00
07403486dc bugfix 2026-04-20 22:06:01 +08:00
733a8d5b35 bugfix 2026-04-20 22:00:10 +08:00
69b905b049 bugfix 2026-04-20 21:58:06 +08:00
eccb3f43b6 bugfix 2026-04-20 21:55:09 +08:00
14615d42f7 bugfix 2026-04-20 21:50:53 +08:00
b6a78f0156 bugfix 2026-04-20 21:49:17 +08:00
e12b217d4e bugfix 2026-04-20 21:39:31 +08:00
3e57154b26 bugfix 2026-04-20 21:32:44 +08:00
e0885481c8 bugfix 2026-04-20 21:27:27 +08:00
50b9dddbdd bugfix 2026-04-09 11:42:25 +08:00
cfb70a9fd3 bugfix 2026-04-08 14:33:09 +08:00
ec91b5d9ce bugfix 2026-04-08 14:05:25 +08:00