From fd30ff445910df99133c5fafcf88c56032af404d Mon Sep 17 00:00:00 2001 From: spions Date: Wed, 7 Oct 2026 09:50:21 +0300 Subject: [PATCH] style: remove added source comments from rerank usage fallback --- litellm/litellm_core_utils/litellm_logging.py | 6 ------ litellm/llms/hosted_vllm/rerank/transformation.py | 6 ------ 2 files changed, 12 deletions(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 37495d5166d..59e358b80bb 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -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") diff --git a/litellm/llms/hosted_vllm/rerank/transformation.py b/litellm/llms/hosted_vllm/rerank/transformation.py index 9017418a71a..40f48af9418 100644 --- a/litellm/llms/hosted_vllm/rerank/transformation.py +++ b/litellm/llms/hosted_vllm/rerank/transformation.py @@ -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) )