@@ -206,7 +206,7 @@ def process_qwen_messages(
206206 messages = []
207207 for m_idx , m in enumerate (_messages ):
208208 role , content = m ["role" ], m ["content" ]
209- func_call , tools_call = m .get ("function_call" , None ), m .get ("tools_call " , None )
209+ func_call , tool_calls = m .get ("function_call" , None ), m .get ("tool_calls " , None )
210210 if content :
211211 content = content .lstrip ("\n " ).rstrip ()
212212 if role in [Role .FUNCTION , Role .TOOL ]:
@@ -227,20 +227,22 @@ def process_qwen_messages(
227227 last_msg = messages [- 1 ]["content" ]
228228 last_msg_has_zh = len (re .findall (r"[\u4e00-\u9fff]+" , last_msg )) > 0
229229
230- if func_call is None and tools_call is None :
231- if functions or tools_call :
230+ if func_call is None and tool_calls is None :
231+ if functions or tool_calls :
232232 content = dummy_thought ["zh" if last_msg_has_zh else "en" ] + content
233233 else :
234234 if func_call :
235235 f_name , f_args = func_call .get ("name" ), func_call .get ("arguments" )
236236 else :
237- f_name , f_args = tools_call [0 ]["function" ]["name" ], tools_call [0 ]["function" ]["arguments" ]
237+ f_name , f_args = tool_calls [0 ]["function" ]["name" ], tool_calls [0 ]["function" ]["arguments" ]
238238 if not content :
239239 if last_msg_has_zh :
240240 content = f"Thought: 我可以使用 { f_name } API。"
241241 else :
242242 content = f"Thought: I can use { f_name } ."
243-
243+
244+ if func_call :
245+ content = f"\n { content } \n Action: { f_name } \n Action Input: { f_args } "
244246 if messages [- 1 ]["role" ] == Role .USER :
245247 messages .append (
246248 ChatCompletionAssistantMessageParam (role = "assistant" , content = content .lstrip ("\n " ).rstrip ())
0 commit comments