@@ -206,7 +206,7 @@ def process_qwen_messages(
206
206
messages = []
207
207
for m_idx , m in enumerate (_messages ):
208
208
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 )
210
210
if content :
211
211
content = content .lstrip ("\n " ).rstrip ()
212
212
if role in [Role .FUNCTION , Role .TOOL ]:
@@ -227,20 +227,22 @@ def process_qwen_messages(
227
227
last_msg = messages [- 1 ]["content" ]
228
228
last_msg_has_zh = len (re .findall (r"[\u4e00-\u9fff]+" , last_msg )) > 0
229
229
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 :
232
232
content = dummy_thought ["zh" if last_msg_has_zh else "en" ] + content
233
233
else :
234
234
if func_call :
235
235
f_name , f_args = func_call .get ("name" ), func_call .get ("arguments" )
236
236
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" ]
238
238
if not content :
239
239
if last_msg_has_zh :
240
240
content = f"Thought: 我可以使用 { f_name } API。"
241
241
else :
242
242
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 } "
244
246
if messages [- 1 ]["role" ] == Role .USER :
245
247
messages .append (
246
248
ChatCompletionAssistantMessageParam (role = "assistant" , content = content .lstrip ("\n " ).rstrip ())
0 commit comments