From cfbcc1764413780c44ae921b44353d6b02886962 Mon Sep 17 00:00:00 2001 From: Selcuk Gun <5055758+selcukgun@users.noreply.github.com> Date: Sat, 12 Apr 2025 17:34:57 -0700 Subject: [PATCH] Fix empty list in content on tool calls causing ollama parse error (#102) This is related to google/adk-python#49 --- src/google/adk/models/lite_llm.py | 2 +- tests/unittests/models/test_litellm.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/adk/models/lite_llm.py b/src/google/adk/models/lite_llm.py index 589a025..acdaa55 100644 --- a/src/google/adk/models/lite_llm.py +++ b/src/google/adk/models/lite_llm.py @@ -178,7 +178,7 @@ def _content_to_message_param( return ChatCompletionAssistantMessage( role=role, - content=_get_content(content.parts), + content=_get_content(content.parts) or None, tool_calls=tool_calls or None, ) diff --git a/tests/unittests/models/test_litellm.py b/tests/unittests/models/test_litellm.py index 6b09b1c..9d9bd71 100644 --- a/tests/unittests/models/test_litellm.py +++ b/tests/unittests/models/test_litellm.py @@ -536,7 +536,7 @@ def test_content_to_message_param_function_call(): content.parts[0].function_call.id = "test_tool_call_id" message = _content_to_message_param(content) assert message["role"] == "assistant" - assert message["content"] == [] + assert message["content"] == None assert message["tool_calls"][0].type == "function" assert message["tool_calls"][0].id == "test_tool_call_id" assert message["tool_calls"][0].function.name == "test_function"