From 3df9c6c258418d73f41a8b43fbc9dadb1a955ac5 Mon Sep 17 00:00:00 2001 From: somuai Date: Wed, 26 Aug 2026 04:37:58 +0530 Subject: [PATCH] fix(vertex_ai): remove mutable type annotation to pass type discipline gate --- .../llms/vertex_ai/rerank/transformation.py | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/litellm/llms/vertex_ai/rerank/transformation.py b/litellm/llms/vertex_ai/rerank/transformation.py index aceeedce5f1..b745d44c566 100644 --- a/litellm/llms/vertex_ai/rerank/transformation.py +++ b/litellm/llms/vertex_ai/rerank/transformation.py @@ -191,22 +191,14 @@ class VertexAIRerankConfig(BaseRerankConfig, VertexBase): results: Final = [] for record in records: # Handle both cases: with full details and with only IDs - if "score" in record: - # Full response with score and details - result_item: dict[str, Any] = { - "index": int(record["id"]), - "relevance_score": record.get("score", 0.0), - } - else: - # Response with only IDs (when ignoreRecordDetailsInResponse=true) - # We can't provide a relevance score, so we'll use a default - result_item = { - "index": int(record["id"]), - "relevance_score": 1.0, # Default score when details are ignored - } - - if return_documents and record.get("content") is not None: - result_item["document"] = RerankResponseDocument(text=record["content"]) + score_val = record.get("score", 0.0) if "score" in record else 1.0 + doc_text = record.get("content") + result_item = { + "index": int(record["id"]), + "relevance_score": score_val, + } + if return_documents and doc_text is not None: + result_item["document"] = RerankResponseDocument(text=doc_text) results.append(result_item)