243 Commits

Author SHA1 Message Date
Hermes Agent
7d8fae01ca fix: check_value支持filter_item级别的value_mode
- check_value增加value_mode参数,优先用传入值,回退到field.value_mode
- filter_item遍历时跳过value_mode key
- 提取filter_item.get('value_mode')传给check_value
- 修复between类型filter报invalid literal for int()错误
2026-06-18 17:49:28 +08:00
Hermes Agent
0d841f078e feat: pricing_program discount field validation [0-1]
- Added rules to discount field: required, number, min:0, max:1
- Frontend: Form validates on submit, shows error below field
- Backend: auto-generated dspy validates before DB write
2026-06-18 17:36:40 +08:00
Hermes Agent
9241edfb6c fix: test_pricing使用urlwidget加载控件JSON 2026-06-18 16:18:28 +08:00
Hermes Agent
edee247a11 fix: test_pricing结果直接返回完整控件JSON
- dspy: 直接return VScrollPanel+Text子控件的完整JSON,不再用status/data包装
- ui: actiontype从urldata改为bricks,直接实例化返回的控件
- 解决status_of模板${items}数组替换不支持的问题
2026-06-18 16:13:52 +08:00
Hermes Agent
d22dbc57ae fix: test_pricing结果用subwidgets控件数组渲染
- dspy: items改为Text控件数组([{widgettype:Text, options:{text:json}}])
- ui: status_of.ok改为VScrollPanel+subwidgets引用items
- 解决之前返回纯文本字符串无法渲染为bricks控件的问题
2026-06-18 16:08:59 +08:00
Hermes Agent
bcdb1e02cd feat: 定价测试窗口添加标题'定价测试' 2026-06-18 16:06:16 +08:00
Hermes Agent
972400e382 feat: test_pricing_program结果每条记录单独显示
- dspy: 每条结果json.dumps(r, ensure_ascii=False)后以\n\n分隔
- ui: 结果区改为VScrollPanel,支持长结果滚动
2026-06-18 16:03:43 +08:00
Hermes Agent
759cd14a56 fix: filters数组改为AND逻辑,缺键视为匹配
- 原OR逻辑导致model不匹配时仅因video匹配就计费
- 带unit_prices的filter_item为tiered定价,跳过AND检查
- seedance2.0案例:390825 tokens从75.82(5条匹配)修正为17.98(1条匹配)
2026-06-18 15:26:04 +08:00
Hermes Agent
616c3a1926 fix: 供应商折扣负数校验,clamp到0~1范围(bug6) 2026-06-16 10:45:29 +08:00
c5eb5b9399 fix: get_pricing_display 异常保护,返回None 2026-06-12 15:32:27 +08:00
c875a8dc2b fix: test_pricing 传入已解析的 dict 导致 yaml.safe_load 报错
ppt_db2app 将 pricing_data 从 YAML 字符串解析为 Python dict,
但 test_pricing 直接传给 get_pricing_from_ymalstr(期望 YAML 字符串),
导致 yaml.safe_load(dict) 报 TypeError。

修复:检测 ppt.pricing_data 类型,如果是 dict 则 yaml.dump 转回字符串。
2026-06-12 15:12:44 +08:00
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