From 0b6b69cd5bfe1b037de5bf1da4c2016942ca6baf Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Wed, 8 Oct 2025 22:19:02 +0530 Subject: [PATCH] fix issue with parsing assistant messages (#15320) * Update factory.py * reinclude the test cases * fixed test --------- Co-authored-by: Weijie --- litellm/litellm_core_utils/prompt_templates/factory.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index c1d8a1cd41..95daa40ca8 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -232,7 +232,6 @@ def ollama_pt( ## MERGE CONSECUTIVE ASSISTANT CONTENT ## while msg_i < len(messages) and messages[msg_i]["role"] == "assistant": assistant_content_str += convert_content_list_to_str(messages[msg_i]) - msg_i += 1 tool_calls = messages[msg_i].get("tool_calls") ollama_tool_calls = [] @@ -258,7 +257,7 @@ def ollama_pt( f"Tool Calls: {json.dumps(ollama_tool_calls, indent=2)}" ) - msg_i += 1 + msg_i += 1 if assistant_content_str: prompt += f"### Assistant:\n{assistant_content_str}\n\n"