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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Fix: Add thought_signatures to VertexGeminiConfig and test
Justas Brazauskasc0ee5da44476
diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.pyindex ba1788a217f..b9f46b540a8 100644--- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py+++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py@@ -1811,6 +1811,7 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):functions: Optional[ChatCompletionToolCallFunctionChunk] = Nonethinking_blocks: Optional[List[ChatCompletionThinkingBlock]] = Nonereasoning_content: Optional[str] = None+ thought_signatures: Optional[Any] = Nonefor idx, candidate in enumerate(_candidates):if "content" not in candidate:diff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_gemini_unbound_local_error.py b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_gemini_unbound_local_error.pynew file mode 100644index 00000000000..0a1ac7e2a54--- /dev/null+++ b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_gemini_unbound_local_error.py@@ -0,0 +1,38 @@+import pytest+from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import VertexGeminiConfig+from litellm import ModelResponse++def test_process_candidates_unbound_local_error_fix():+ # Setup+ candidates = [+ {+ "content": {+ "role": "model"+ # "parts" is missing intentionally to trigger the issue+ },+ "finishReason": "STOP"+ }+ ]+ model_response = ModelResponse()++ # Execution+ try:+ VertexGeminiConfig._process_candidates(+ _candidates=candidates,+ model_response=model_response,+ standard_optional_params={},+ cumulative_tool_call_index=0+ )+ except UnboundLocalError as e:+ pytest.fail(f"UnboundLocalError raised: {e}")+ except Exception as e:+ # Other exceptions might be okay if they are not UnboundLocalError,+ # but ideally it should pass without error or raise a specific error if parts are required.+ # However, the goal is to verify thought_signatures doesn't crash.+ pass++ # Verify that we didn't crash with UnboundLocalError++if __name__ == "__main__":+ test_process_candidates_unbound_local_error_fix()+ print("Test passed!")