fix: harden the observability fields against the verifier findings

This commit is contained in:
2026-07-31 08:28:41 -04:00
parent 966d548245
commit 32d7869043
9 changed files with 148 additions and 10 deletions
+2 -1
View File
@@ -99,7 +99,8 @@ class PricingTable:
logger.warning("pricing 表无 model {!r} 的单价,cost 记 None", model)
return None
billed_input = prompt_tokens / 1_000_000 * price.input_per_1m
if price.cached_input_per_1m is not None and cached_prompt_tokens:
# 负数按"无命中"处理: cost() 是公共方法,不能假定调用方已过 transport 的校验
if price.cached_input_per_1m is not None and (cached_prompt_tokens or 0) > 0:
cached = self._clamp_cached(model, prompt_tokens, cached_prompt_tokens)
billed_input = (prompt_tokens - cached) / 1_000_000 * price.input_per_1m + (
cached / 1_000_000 * price.cached_input_per_1m