[Bugfix] fixed deepseekv32 tool calling error (#30025)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
Chauncey 2025-12-04 15:12:12 +08:00 committed by GitHub
parent 9ae2f60374
commit 82a64b3d8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -95,8 +95,10 @@ def tool_calls_to_openai_format(tool_calls):
def encode_arguments_to_dsml(tool_call: dict[str, str]) -> str: def encode_arguments_to_dsml(tool_call: dict[str, str]) -> str:
p_dsml_template = """<{dsml_token}parameter name="{key}" string="{is_str}">{value}</{dsml_token}parameter>""" p_dsml_template = """<{dsml_token}parameter name="{key}" string="{is_str}">{value}</{dsml_token}parameter>"""
P_dsml_strs = [] P_dsml_strs = []
if isinstance(tool_call["arguments"], str):
arguments = json.loads(tool_call["arguments"]) arguments = json.loads(tool_call["arguments"])
else:
arguments = tool_call["arguments"]
for k, v in arguments.items(): for k, v in arguments.items():
p_dsml_str = p_dsml_template.format( p_dsml_str = p_dsml_template.format(

View File

@ -43,7 +43,8 @@ class DeepseekV32Tokenizer(HfTokenizer):
thinking_mode = "thinking" thinking_mode = "thinking"
if not thinking: if not thinking:
thinking_mode = "chat" thinking_mode = "chat"
messages = messages.copy() conversation = kwargs.get("conversation", messages)
messages = conversation.copy()
drop_thinking = True drop_thinking = True
if tools is not None and len(tools) > 0: if tools is not None and len(tools) > 0:
messages.insert(0, {"role": "system"}) messages.insert(0, {"role": "system"})