|
|
@@ -1,5 +1,6 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
+import re
|
|
|
from datetime import datetime
|
|
|
from typing import List, Optional, Union
|
|
|
from urllib.parse import urlparse
|
|
|
@@ -220,11 +221,21 @@ async def get_public_prices(
|
|
|
parsed_prices: List[ParsedPriceItem] = []
|
|
|
discounted_prices: List[DiscountedPriceItem] = []
|
|
|
|
|
|
+ # 只保留输入/输出主价格,过滤掉缓存命中、Batch File、调优等附加价格
|
|
|
+ _EXCLUDED_LABEL_RE = re.compile(
|
|
|
+ r"缓存|batch\s*file|批量|调优|思考模式",
|
|
|
+ re.I,
|
|
|
+ )
|
|
|
+
|
|
|
for r in rows:
|
|
|
for item in parse_prices(_j(r["prices"]) or {}):
|
|
|
# 过滤掉输入和输出价格都为 None 的条目(保留单边价格,如向量模型、图像生成等)
|
|
|
if item.get("input_price") is None and item.get("output_price") is None:
|
|
|
continue
|
|
|
+ # 过滤掉缓存命中、Batch File、调优等非主价格条目
|
|
|
+ label = item.get("label") or ""
|
|
|
+ if _EXCLUDED_LABEL_RE.search(label):
|
|
|
+ continue
|
|
|
# 将 label 改为中文
|
|
|
item = dict(item)
|
|
|
if item.get("label") == "input/output":
|