@@ -329,23 +329,19 @@ def parse_chat_output(
329329 token_ids : Sequence [int ]) -> tuple [Optional [str ], Optional [str ], bool ]:
330330 parser = parse_output_into_messages (token_ids )
331331 output_msgs = parser .messages
332+ is_tool_call = False # TODO: update this when tool call is supported
332333 if len (output_msgs ) == 0 :
333334 # The generation has stopped during reasoning.
334- is_tool_call = False
335335 reasoning_content = parser .current_content
336336 final_content = None
337337 elif len (output_msgs ) == 1 :
338338 # The generation has stopped during final message.
339- is_tool_call = False
340339 reasoning_content = output_msgs [0 ].content [0 ].text
341340 final_content = parser .current_content
342341 else :
343- if len (output_msgs ) != 2 :
344- raise ValueError (
345- "Expected 2 output messages (reasoning and final), "
346- f"but got { len (output_msgs )} ." )
347- reasoning_msg , final_msg = output_msgs
348- reasoning_content = reasoning_msg .content [0 ].text
342+ reasoning_msg = output_msgs [:- 1 ]
343+ final_msg = output_msgs [- 1 ]
344+ reasoning_content = "\n " .join (
345+ [msg .content [0 ].text for msg in reasoning_msg ])
349346 final_content = final_msg .content [0 ].text
350- is_tool_call = final_msg .recipient is not None
351347 return reasoning_content , final_content , is_tool_call
0 commit comments