fix issue with parsing assistant messages (#15320)

* Update factory.py

* reinclude the test cases

* fixed test

---------

Co-authored-by: Weijie <weijie-tan3@github.com>
This commit is contained in:
Sameer Kankute
2025-10-08 09:49:02 -07:00
committed by GitHub
co-authored by Weijie
parent 13703f289b
commit 0b6b69cd5b
@@ -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"