style: remove added source comments from rerank usage fallback

This commit is contained in:
spions 2026-10-07 09:50:21 +03:00
parent 05d54f5446
commit fd30ff4459
2 changed files with 0 additions and 12 deletions

View file

@ -5731,12 +5731,6 @@ class StandardLoggingPayloadSetup:
@staticmethod
def _get_rerank_usage_from_meta(meta: object) -> Usage | None:
"""
RerankResponse has no top-level `usage` field - token usage lives under
`meta.billed_units`/`meta.tokens` instead (Cohere-style API). Some servers
report only one of the two fields; since rerank has no completion step,
cross-fill so a lone `tokens.input_tokens` still yields a nonzero total.
"""
if not isinstance(meta, dict) or ("billed_units" not in meta and "tokens" not in meta):
return None
billed_units: Final = meta.get("billed_units")

View file

@ -202,9 +202,6 @@ class HostedVLLMRerankConfig(BaseRerankConfig):
return HostedVLLMRerankError(message=error_message, status_code=status_code, headers=headers)
def _transform_response(self, response: dict) -> RerankResponse:
# Extract usage information - some servers (vLLM/Cohere-style) return a
# top-level `meta` object; others (OpenAI/TEI-style) return `usage`.
# Check both so either shape is picked up.
raw_meta: Final = response.get("meta")
usage_data: Final = response.get("usage")
meta_billed_units: Final = raw_meta.get("billed_units") if isinstance(raw_meta, dict) else None
@ -212,9 +209,6 @@ class HostedVLLMRerankConfig(BaseRerankConfig):
usage_total_tokens: Final = usage_data.get("total_tokens", 0) if isinstance(usage_data, dict) else 0
meta_total: Final = meta_billed_units.get("total_tokens") if isinstance(meta_billed_units, dict) else None
meta_input: Final = meta_tokens.get("input_tokens") if isinstance(meta_tokens, dict) else None
# Rerank has no completion step, so a server reporting only one of the two
# meta fields still gives us the full token count; cross-fill before
# falling back to the OpenAI/TEI-style top-level `usage` field.
total_tokens: Final = (
meta_total if meta_total is not None else (meta_input if meta_input is not None else usage_total_tokens)
)