fix: keep the postgres backfill from disabling telemetry or locking the table
This commit is contained in:
@@ -47,6 +47,8 @@ class PricingTable:
|
||||
def __init__(self, prices: Mapping[str, ModelPrice]) -> None:
|
||||
self._prices = dict(prices)
|
||||
self._warned: set[str] = set()
|
||||
# 独立集合: 与"未知 model"的告警去重键分开,避免 model 名恰好撞上时互相抑制
|
||||
self._warned_clamp: set[str] = set()
|
||||
|
||||
@classmethod
|
||||
def from_file(cls, path: Path | str) -> PricingTable:
|
||||
@@ -111,9 +113,8 @@ class PricingTable:
|
||||
"""命中数按输入总数夹取: 网关口径异常不得算出负成本(每 model 只警告一次)。"""
|
||||
if cached <= prompt_tokens:
|
||||
return cached
|
||||
key = f"{model}:cached_over_prompt"
|
||||
if key not in self._warned:
|
||||
self._warned.add(key)
|
||||
if model not in self._warned_clamp:
|
||||
self._warned_clamp.add(model)
|
||||
logger.warning(
|
||||
"model {!r} 上报的缓存命中 {} 超过输入总数 {},按总数夹取计价",
|
||||
model,
|
||||
|
||||
Reference in New Issue
Block a user