232 Commits

Author SHA1 Message Date
7df8e530a4 remove: pricing_item CRUD and related functions (not used) 2026-06-12 14:41:58 +08:00
ac3d7c6d91 fix: implement missing get_all_spec_fields_by_pptid, sor_get_spec_fields, get_pricing_specs_by_pptid 2026-06-12 14:18:52 +08:00
00abc0caa4 bugfix 2026-06-12 14:04:57 +08:00
c8b5bba342 bugfix 2026-06-12 13:55:10 +08:00
8d1808fe96 bgufix 2026-06-12 13:49:27 +08:00
9094e07465 bgufix 2026-06-12 13:47:09 +08:00
22a3a96833 bgufix 2026-06-12 13:03:55 +08:00
fffcd03c87 fix: remove nonexistent ownerid filter from pricing_program_timing CRUD 2026-06-11 16:30:57 +08:00
c2a7dbb98f docs: 添加HTTP API文档和pricing_data使用指南
1. HTTP API接口文档:get_pricing_display.dspy 调用方式和返回示例
2. pricing_data两种格式说明:新格式(price_factors+unit_prices+unit)和旧格式(formula)
3. 完整示例:Token定价、视频生成定价、公式计算定价
4. 关键规则说明:unit_values、filters格式、value_mode等
2026-06-05 19:18:46 +08:00
c1bfaca049 fix: 支持filters列表格式 + display_text展示过滤条件
1. 从 p['filters'] 列表提取filter条件(数据库实际存储格式)
2. 兼容dict直接字段和list两种filter格式
3. tiered仅用于价格不同的阶梯定价
4. display_text展示每条定价的过滤条件
2026-06-05 19:07:11 +08:00
502468e0cb fix: model filter提升为item级适用条件
- model filter从tiered移到item.filters(适用条件)
- tiered只保留区间阶梯定价(如token范围)
- 区分适用条件vs阶梯定价的业务语义
2026-06-05 18:53:33 +08:00
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
392f281758 fix: replace wildcard patterns with explicit per-file entries in load_path.py 2026-06-04 13:03: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
71329af722 fix: 定价管理菜单直接进入pricing_program CRUD,跳过index.ui 2026-06-01 15:55:20 +08:00
12472b792f fix: reduce module card height (remove cheight, compact padding/icons) 2026-05-30 21:20:48 +08:00
fc1f8bb182 fix: wrap Tabular in VBox with cheight for proper scrolling 2026-05-29 22:09:53 +08:00
8159c79d55 feat: respect module_cache config for pricing cache 2026-05-29 17:59:06 +08:00
c041c76c9f refactor: use wildcard % in load_path.py for auto-coverage 2026-05-29 00:52:20 +08:00
b7e69b48cd fix: responsive UI with VScrollPanel, cfontsize, css:card 2026-05-29 00:12:52 +08:00
5813749a98 bugfix 2026-05-27 18:17:44 +08:00
c1bdc467a6 refactor(models): convert to json format per database-table-definition-spec 2026-05-27 13:23:30 +08:00
6379c1a0e3 feat: add load_path.py RBAC permission registration script 2026-05-27 13:16:09 +08:00
ce5062215e fix: remove hardcoded dark theme colors from index.ui
- Remove bgcolor/color/border hardcoded dark theme values
- Use css:'card' class for navigation card
- Let system theme handle styling for proper contrast
2026-05-27 11:31:15 +08:00
0e9a0ef126 fix: add filler css + overflowY:auto to content container 2026-05-26 13:55:19 +08:00
bf868f3f3a fix: add dark mode background (#0B1120) to pricing index.ui 2026-05-26 11:57:18 +08:00
7c41db3f9b feat: modernize pricing UI - add index.ui with card navigation
- Create index.ui with standardized card layout (#1E293B, 12px radius)
- Simplify menu.ui to point to index.ui entry point
- Add page header with Title2 + description text
- Use consistent SVG icon style (36px, 1.5 stroke width)
2026-05-25 18:30:48 +08:00
fc54699be7 feat: add json table definitions for all models (converted from xlsx) 2026-05-21 12:46:36 +08:00
9ccbb47920 bugfix 2026-05-19 12:09:52 +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