From 0607a0fa5cee3b20b980f4de6b393bf033b1aea6 Mon Sep 17 00:00:00 2001 From: Dong_master <2213070223@qq.com> Date: Tue, 12 Aug 2025 00:04:21 +0800 Subject: [PATCH] fix: in the modelscopechatcmpl.py stream tool_calls arguments bug, --- .../modelmgr/requesters/modelscopechatcmpl.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/provider/modelmgr/requesters/modelscopechatcmpl.py b/pkg/provider/modelmgr/requesters/modelscopechatcmpl.py index 9d8861da..d45c5d9e 100644 --- a/pkg/provider/modelmgr/requesters/modelscopechatcmpl.py +++ b/pkg/provider/modelmgr/requesters/modelscopechatcmpl.py @@ -290,15 +290,19 @@ class ModelScopeChatCompletions(requester.ProviderAPIRequester): # 处理工具调用增量 if delta.get('tool_calls'): + print(delta.get('tool_calls')) for tool_call in delta['tool_calls']: - if tool_call['id'] and tool_call['function']['name']: + if tool_call['id'] != '': tool_id = tool_call['id'] + if tool_call['function']['name'] is not None: tool_name = tool_call['function']['name'] - else: - tool_call['id'] = tool_id - tool_call['function']['name'] = tool_name + if tool_call['type'] is None: tool_call['type'] = 'function' + tool_call['id'] = tool_id + tool_call['function']['name'] = tool_name + tool_call['function']['arguments'] = "" if tool_call['function']['arguments'] is None else tool_call['function']['arguments'] + # 跳过空的第一个 chunk(只有 role 没有内容) if chunk_idx == 0 and not delta_content and not reasoning_content and not delta.get('tool_calls'):