diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.py index 65cdddd6c01..be5fec2c224 100644 --- a/litellm/llms/vertex_ai/gemini/transformation.py +++ b/litellm/llms/vertex_ai/gemini/transformation.py @@ -991,9 +991,8 @@ def _gemini_convert_messages_with_history( # noqa: PLR0915 # copy it to parallel function calls missing thoughtSignature. turn_thought_signature = None for existing_part in assistant_content: - if ( - isinstance(existing_part, dict) - and existing_part.get("thoughtSignature") + if isinstance(existing_part, dict) and existing_part.get( + "thoughtSignature" ): turn_thought_signature = existing_part.get( "thoughtSignature" diff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.py b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.py index 68de50d3b0c..3c3e05390eb 100644 --- a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.py +++ b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_ai_gemini_transformation.py @@ -563,7 +563,9 @@ def test_parallel_tool_calls_copy_thought_signature_from_thinking_block(): assert len(contents) == 1 model_parts = contents[0]["parts"] function_parts = [ - p for p in model_parts if p.get("functionCall") is not None or p.get("function_call") is not None + p + for p in model_parts + if p.get("functionCall") is not None or p.get("function_call") is not None ] assert len(function_parts) == 2 assert all(p.get("thoughtSignature") == "sig-turn-123" for p in function_parts) @@ -613,9 +615,7 @@ def test_parallel_tool_calls_copy_thought_signature_from_text_thinking_block(): if p.get("functionCall") is not None or p.get("function_call") is not None ] assert len(function_parts) == 2 - assert all( - p.get("thoughtSignature") == "sig-text-thinking" for p in function_parts - ) + assert all(p.get("thoughtSignature") == "sig-text-thinking" for p in function_parts) def test_thought_signature_with_function_call_mode(): diff --git a/tests/test_litellm/llms/vertex_ai/test_vertex.py b/tests/test_litellm/llms/vertex_ai/test_vertex.py index be0e59e8b7d..a3dee0376f3 100644 --- a/tests/test_litellm/llms/vertex_ai/test_vertex.py +++ b/tests/test_litellm/llms/vertex_ai/test_vertex.py @@ -393,8 +393,8 @@ def test_multiple_function_call(): "role": "model", "parts": [ {"text": "test"}, - {"function_call": {"name": "test", "args": {"arg": "test"}}}, - {"function_call": {"name": "test2", "args": {"arg": "test2"}}}, + {"functionCall": {"name": "test", "args": {"arg": "test"}}}, + {"functionCall": {"name": "test2", "args": {"arg": "test2"}}}, ], }, { @@ -502,8 +502,8 @@ def test_multiple_function_call_changed_text_pos(): "role": "model", "parts": [ {"text": "test"}, - {"function_call": {"name": "test", "args": {"arg": "test"}}}, - {"function_call": {"name": "test2", "args": {"arg": "test2"}}}, + {"functionCall": {"name": "test", "args": {"arg": "test"}}}, + {"functionCall": {"name": "test2", "args": {"arg": "test2"}}}, ], }, { @@ -1282,7 +1282,6 @@ def test_process_gemini_media(): assert base64_result["inline_data"]["data"] == "/9j/4AAQSkZJRg..." - def test_get_image_mime_type_from_url(): """Test the _get_image_mime_type_from_url function for different image URLs""" from litellm.llms.vertex_ai.gemini.transformation import (