fix: model过滤支持model_mappings映射,含mappings的单模型ppid也能正确过滤

This commit is contained in:
yumoqing 2026-07-06 18:06:02 +08:00
parent d7d02ccb6b
commit a7d88309b8

View File

@ -797,6 +797,7 @@ async def get_pricing_display(ppid, model=None):
pricings = d.get('pricings', []) pricings = d.get('pricings', [])
pricing_type = d.get('pricing_type', 'per_use') pricing_type = d.get('pricing_type', 'per_use')
unit_values = d.get('unit_values', {'百万': 1000000, '': 1, '': 1000, '': 1, '': 1, '毫秒': 0.001, '元/百万tokens': 1000000, '元/total_tokens': 1, '元/times': 1}) unit_values = d.get('unit_values', {'百万': 1000000, '': 1, '': 1000, '': 1, '': 1, '毫秒': 0.001, '元/百万tokens': 1000000, '元/total_tokens': 1, '元/times': 1})
model_mappings = d.get('model_mappings', {})
items = [] items = []
for p in pricings: for p in pricings:
@ -929,7 +930,8 @@ async def get_pricing_display(ppid, model=None):
item_model = item['filters'].get('model') item_model = item['filters'].get('model')
if not item_model and item.get('filter_labels'): if not item_model and item.get('filter_labels'):
item_model = item['filter_labels'].get('模型') item_model = item['filter_labels'].get('模型')
if item_model == model: # 直接匹配或通过 model_mappings 映射匹配
if item_model == model or model_mappings.get(item_model) == model:
filtered_items.append(item) filtered_items.append(item)
if filtered_items: if filtered_items:
items = filtered_items items = filtered_items