Răsfoiți Sursa

修改请求publics接口的json格式

lxylxy123321 1 lună în urmă
părinte
comite
fffc216db3
1 a modificat fișierele cu 7 adăugiri și 0 ștergeri
  1. 7 0
      backend/app/routers/public.py

+ 7 - 0
backend/app/routers/public.py

@@ -222,6 +222,13 @@ async def get_public_prices(
 
 
     for r in rows:
     for r in rows:
         for item in parse_prices(_j(r["prices"]) or {}):
         for item in parse_prices(_j(r["prices"]) or {}):
+            # 只保留同时有输入和输出价格的条目,过滤掉 Batch、缓存命中等单边价格
+            if item.get("input_price") is None or item.get("output_price") is None:
+                continue
+            # 将 label 改为中文
+            item = dict(item)
+            if item.get("label") == "input/output":
+                item["label"] = "输入/输出"
             parsed_prices.append(ParsedPriceItem(url=r["url"], model_name=r["model_name"], **item))
             parsed_prices.append(ParsedPriceItem(url=r["url"], model_name=r["model_name"], **item))
             d_item = dict(item)
             d_item = dict(item)
             model_name = r["model_name"]
             model_name = r["model_name"]