From 3c19eba7c4b435727ecea53af37008c1b65d3dba Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 29 Apr 2026 16:14:26 -0600 Subject: [PATCH] Fix gemini tools call --- frigate/genai/gemini.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/frigate/genai/gemini.py b/frigate/genai/gemini.py index cfa9cb802..c4befbe90 100644 --- a/frigate/genai/gemini.py +++ b/frigate/genai/gemini.py @@ -143,15 +143,17 @@ class GeminiClient(GenAIClient): ) elif role == "tool": # Handle tool response - function_response = { - "name": msg.get("name", ""), - "response": content, - } + response_payload = ( + content if isinstance(content, dict) else {"result": content} + ) gemini_messages.append( types.Content( role="function", parts=[ - types.Part.from_function_response(function_response) # type: ignore[misc,call-arg,arg-type] + types.Part.from_function_response( + name=msg.get("name", ""), + response=response_payload, + ) ], ) ) @@ -350,15 +352,17 @@ class GeminiClient(GenAIClient): ) elif role == "tool": # Handle tool response - function_response = { - "name": msg.get("name", ""), - "response": content, - } + response_payload = ( + content if isinstance(content, dict) else {"result": content} + ) gemini_messages.append( types.Content( role="function", parts=[ - types.Part.from_function_response(function_response) # type: ignore[misc,call-arg,arg-type] + types.Part.from_function_response( + name=msg.get("name", ""), + response=response_payload, + ) ], ) )