Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

merge: resolve litellm_internal_staging conflicts in vertex rerank transformation

shivam5bd4aab26ff4
diff --cc litellm/llms/vertex_ai/rerank/transformation.py
index 69ffd4a2b42,2ec4f2da79b..d446aa121f0
--- a/litellm/llms/vertex_ai/rerank/transformation.py
+++ b/litellm/llms/vertex_ai/rerank/transformation.py
@@@ -4,9 -4,8 +4,10 @@@ Translates from Cohere's `/v1/rerank` i
Why separate file? Make it easy to see how transformation works
"""
+import math
+import uuid
- from typing import Any, Dict, List, Union
+ from collections.abc import Mapping
+ from typing import Any, Final
import httpx
@@@ -210,12 -208,10 +212,11 @@@ class VertexAIRerankConfig(BaseRerankCo
RerankResponseResult(index=result["index"], relevance_score=result["relevance_score"])
)
- input_record_count = len(request_data.get("records", []))
- search_units = math.ceil(input_record_count / self.MAX_RECORDS_PER_SEARCH_UNIT)
-
- meta = RerankResponseMeta(billed_units=RerankBilledUnits(search_units=search_units))
- # Create meta object
- meta: Final = RerankResponseMeta(billed_units=RerankBilledUnits(search_units=len(records)))
++ input_record_count: Final = len(request_data.get("records", []))
++ search_units: Final = math.ceil(input_record_count / self.MAX_RECORDS_PER_SEARCH_UNIT)
++ meta: Final = RerankResponseMeta(billed_units=RerankBilledUnits(search_units=search_units))
- return RerankResponse(id=f"vertex_ai_rerank_{model}", results=rerank_results, meta=meta)
+ return RerankResponse(id=f"vertex_ai_rerank_{uuid.uuid4()}", results=rerank_results, meta=meta)
def get_supported_cohere_rerank_params(self, model: str) -> list:
return [