lmdeploy icon indicating copy to clipboard operation
lmdeploy copied to clipboard

[Feature] qwen3 coder与qwen3的工具调用逻辑有差异,需要额外适配

Open YangWuuu opened this issue 4 months ago • 4 comments

Motivation

qwen3工具调用是json格式,qwen3 code的工具调用切换到xml格式

Related resources

qwen3 工具调用:

{%- for tool in tools %} -- {{- "\n" }} {{- tool \| tojson }} {%- endfor %}

工具回复: <tool_call>\n{"name": , "arguments": }\n</tool_call>

qwen3 code 工具调用:

{%- for param_name, param_fields in tool.parameters.properties\|items %} -- {{- '\n' }} {{- '\n' ~ param_name ~ '' }} {%- if param_fields.type is defined %} {{- '\n' ~ (param_fields.type \| string) ~ '' }} {%- endif %} {%- if param_fields.description is defined %} {{- '\n' ~ (param_fields.description \| trim) ~ '' }} {%- endif %} {%- set handled_keys = ['name', 'type', 'description'] %} {{- render_extra_keys(param_fields, handled_keys) }} {{- '\n' }} {%- endfor %}

工具回复: <tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n\n\n</tool_call>

Additional context

No response

YangWuuu avatar Aug 14 '25 00:08 YangWuuu

我也有相同的需求,期待早日能支持qwen3_coder tools解析。通过jijna template 是否能实现coder的工具调用,是否有人试过?

kukukalaz avatar Sep 04 '25 13:09 kukukalaz

We will appreciate it if you guys could PR us.

RunningLeon avatar Sep 05 '25 02:09 RunningLeon

@RunningLeon

我在尝试适配 qwen3 coder 的 tools parser 时, 会报告这个一样的错误 : https://github.com/InternLM/lmdeploy/issues/3967

有任何分析的思路吗? 应该从哪些部分(思路)入手来分析呢?

KevinLiuMY avatar Sep 13 '25 04:09 KevinLiuMY

@RunningLeon

我在尝试适配 qwen3 coder 的 tools parser 时, 会报告这个一样的错误 : #3967

有任何分析的思路吗? 应该从哪些部分(思路)入手来分析呢?

@KevinLiuMY sorry for the late reply, pls check https://github.com/InternLM/lmdeploy/issues/3967#issuecomment-3294904450

RunningLeon avatar Sep 16 '25 04:09 RunningLeon