From c84221cafba7142bd7233b5926ed29d01cd38000 Mon Sep 17 00:00:00 2001 From: apex-mochen <2756823972@qq.com> Date: Sat, 10 Oct 2026 12:40:00 +0000 Subject: [PATCH] fix(vertex): guard embedding response 'predictions' without redundant isinstance basedpyright flags `isinstance(response, dict)` as reportUnnecessaryIsInstance because `transform_vertex_response_to_openai` already annotates `response: dict`; two new calls pushed that rule past its committed budget in CI. Keep the defensive contract (raise ValueError when the response body lacks the 'predictions' key) but drop the redundant isinstance narrow. Signed-off-by: apex-mochen <2756823972@qq.com> --- litellm/llms/vertex_ai/vertex_embeddings/transformation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/vertex_ai/vertex_embeddings/transformation.py b/litellm/llms/vertex_ai/vertex_embeddings/transformation.py index dd3dbfa0319..eae42a980b9 100644 --- a/litellm/llms/vertex_ai/vertex_embeddings/transformation.py +++ b/litellm/llms/vertex_ai/vertex_embeddings/transformation.py @@ -229,7 +229,7 @@ class VertexAITextEmbeddingConfig(LiteLLMBaseModel): if VertexBGEConfig.is_bge_model(model): return VertexBGEConfig.transform_response(response=response, model=model, model_response=model_response) - if not isinstance(response, dict) or "predictions" not in response: + if "predictions" not in response: raise ValueError("Vertex embedding response missing 'predictions' field") _predictions: Final = response["predictions"] @@ -260,7 +260,7 @@ class VertexAITextEmbeddingConfig(LiteLLMBaseModel): """ Transforms a vertex fine-tuned model embedding response to an openai response format. """ - if not isinstance(response, dict) or "predictions" not in response: + if "predictions" not in response: raise ValueError("Vertex embedding response missing 'predictions' field") _predictions: Final = response["predictions"]