Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/source/Instruction/支持的模型和数据集.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@
|[Qwen/Qwen3-235B-A22B-Instruct-2507](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Instruct-2507)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|-|[Qwen/Qwen3-235B-A22B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507)|
|[Qwen/Qwen3-235B-A22B-Instruct-2507-FP8](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Instruct-2507-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|-|[Qwen/Qwen3-235B-A22B-Instruct-2507-FP8](https://huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507-FP8)|
|[swift/Qwen3-235B-A22B-Instruct-2507-AWQ](https://modelscope.cn/models/swift/Qwen3-235B-A22B-Instruct-2507-AWQ)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|-|-|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct)|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|
|[swift/Qwen3-Coder-480B-A35B-Instruct-AWQ](https://modelscope.cn/models/swift/Qwen3-Coder-480B-A35B-Instruct-AWQ)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|coding|-|
|[Qwen/Qwen3-4B-Instruct-2507](https://modelscope.cn/models/Qwen/Qwen3-4B-Instruct-2507)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|-|[Qwen/Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507)|
|[Qwen/Qwen3-4B-Instruct-2507-FP8](https://modelscope.cn/models/Qwen/Qwen3-4B-Instruct-2507-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|-|[Qwen/Qwen3-4B-Instruct-2507-FP8](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507-FP8)|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct)|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|
|[swift/Qwen3-Coder-480B-A35B-Instruct-AWQ](https://modelscope.cn/models/swift/Qwen3-Coder-480B-A35B-Instruct-AWQ)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|-|
|[Qwen/Qwen3-30B-A3B-Base](https://modelscope.cn/models/Qwen/Qwen3-30B-A3B-Base)|qwen3_moe|qwen3|transformers>=4.51|✔|-|[Qwen/Qwen3-30B-A3B-Base](https://huggingface.co/Qwen/Qwen3-30B-A3B-Base)|
|[Qwen/Qwen3-30B-A3B](https://modelscope.cn/models/Qwen/Qwen3-30B-A3B)|qwen3_moe|qwen3|transformers>=4.51|✔|-|[Qwen/Qwen3-30B-A3B](https://huggingface.co/Qwen/Qwen3-30B-A3B)|
|[Qwen/Qwen3-235B-A22B](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B)|qwen3_moe|qwen3|transformers>=4.51|✔|-|[Qwen/Qwen3-235B-A22B](https://huggingface.co/Qwen/Qwen3-235B-A22B)|
Expand Down
10 changes: 5 additions & 5 deletions docs/source_en/Instruction/Supported-models-and-datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ The table below introduces the models integrated with ms-swift:
|[Qwen/Qwen3-235B-A22B-Instruct-2507](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Instruct-2507)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|-|[Qwen/Qwen3-235B-A22B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507)|
|[Qwen/Qwen3-235B-A22B-Instruct-2507-FP8](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B-Instruct-2507-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|-|[Qwen/Qwen3-235B-A22B-Instruct-2507-FP8](https://huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507-FP8)|
|[swift/Qwen3-235B-A22B-Instruct-2507-AWQ](https://modelscope.cn/models/swift/Qwen3-235B-A22B-Instruct-2507-AWQ)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|-|-|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct)|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|
|[swift/Qwen3-Coder-480B-A35B-Instruct-AWQ](https://modelscope.cn/models/swift/Qwen3-Coder-480B-A35B-Instruct-AWQ)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|coding|-|
|[Qwen/Qwen3-4B-Instruct-2507](https://modelscope.cn/models/Qwen/Qwen3-4B-Instruct-2507)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✔|-|[Qwen/Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507)|
|[Qwen/Qwen3-4B-Instruct-2507-FP8](https://modelscope.cn/models/Qwen/Qwen3-4B-Instruct-2507-FP8)|qwen3_nothinking|qwen3_nothinking|transformers>=4.51|✘|-|[Qwen/Qwen3-4B-Instruct-2507-FP8](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507-FP8)|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct)|
|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct)|
|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://modelscope.cn/models/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|[Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8](https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8)|
|[swift/Qwen3-Coder-480B-A35B-Instruct-AWQ](https://modelscope.cn/models/swift/Qwen3-Coder-480B-A35B-Instruct-AWQ)|qwen3_coder|qwen3_coder|transformers>=4.51|✘|coding|-|
|[Qwen/Qwen3-30B-A3B-Base](https://modelscope.cn/models/Qwen/Qwen3-30B-A3B-Base)|qwen3_moe|qwen3|transformers>=4.51|✔|-|[Qwen/Qwen3-30B-A3B-Base](https://huggingface.co/Qwen/Qwen3-30B-A3B-Base)|
|[Qwen/Qwen3-30B-A3B](https://modelscope.cn/models/Qwen/Qwen3-30B-A3B)|qwen3_moe|qwen3|transformers>=4.51|✔|-|[Qwen/Qwen3-30B-A3B](https://huggingface.co/Qwen/Qwen3-30B-A3B)|
|[Qwen/Qwen3-235B-A22B](https://modelscope.cn/models/Qwen/Qwen3-235B-A22B)|qwen3_moe|qwen3|transformers>=4.51|✔|-|[Qwen/Qwen3-235B-A22B](https://huggingface.co/Qwen/Qwen3-235B-A22B)|
Expand Down
1 change: 1 addition & 0 deletions swift/llm/model/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class LLMModelType:
qwen3 = 'qwen3'
qwen3_thinking = 'qwen3_thinking'
qwen3_nothinking = 'qwen3_nothinking'
qwen3_coder = 'qwen3_coder'
qwen3_moe = 'qwen3_moe'
qwen3_moe_thinking = 'qwen3_moe_thinking'
qwen3_next = 'qwen3_next'
Expand Down
23 changes: 17 additions & 6 deletions swift/llm/model/model/qwen.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@ def _get_cast_dtype(self) -> torch.dtype:
# awq
Model('swift/Qwen3-235B-A22B-Instruct-2507-AWQ'),
]),
ModelGroup([
Model('Qwen/Qwen3-4B-Instruct-2507', 'Qwen/Qwen3-4B-Instruct-2507'),
Model('Qwen/Qwen3-4B-Instruct-2507-FP8', 'Qwen/Qwen3-4B-Instruct-2507-FP8'),
])
],
TemplateType.qwen3_nothinking,
get_model_tokenizer_with_flash_attn,
architectures=['Qwen3MoeForCausalLM', 'Qwen3ForCausalLM'],
requires=['transformers>=4.51'],
))

register_model(
ModelMeta(
LLMModelType.qwen3_coder,
[
ModelGroup([
Model('Qwen/Qwen3-Coder-30B-A3B-Instruct', 'Qwen/Qwen3-Coder-30B-A3B-Instruct'),
Model('Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8', 'Qwen/Qwen3-Coder-30B-A3B-Instruct-FP8'),
Expand All @@ -594,14 +609,10 @@ def _get_cast_dtype(self) -> torch.dtype:
Model('swift/Qwen3-Coder-480B-A35B-Instruct-AWQ'),
],
tags=['coding']),
ModelGroup([
Model('Qwen/Qwen3-4B-Instruct-2507', 'Qwen/Qwen3-4B-Instruct-2507'),
Model('Qwen/Qwen3-4B-Instruct-2507-FP8', 'Qwen/Qwen3-4B-Instruct-2507-FP8'),
])
],
TemplateType.qwen3_nothinking,
TemplateType.qwen3_coder,
get_model_tokenizer_with_flash_attn,
architectures=['Qwen3MoeForCausalLM', 'Qwen3ForCausalLM'],
architectures=['Qwen3MoeForCausalLM'],
requires=['transformers>=4.51'],
))

Expand Down
2 changes: 1 addition & 1 deletion swift/llm/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def _get_system(self, inputs: StdTemplateInputs) -> Optional[str]:
system = template_meta.default_system

if tools is not None:
system = self.agent_template._format_tools(tools, system or '', inputs.messages[0])
system = self.agent_template._format_tools(tools, system, inputs.messages[0])
return system

def _swift_prepare_inputs(self, inputs: StdTemplateInputs):
Expand Down
1 change: 1 addition & 0 deletions swift/llm/template/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class LLMTemplateType:
qwen3 = 'qwen3'
qwen3_thinking = 'qwen3_thinking'
qwen3_nothinking = 'qwen3_nothinking'
qwen3_coder = 'qwen3_coder'
qwen3_emb = 'qwen3_emb'
qwen3_reranker = 'qwen3_reranker'
qwq_preview = 'qwq_preview'
Expand Down
2 changes: 2 additions & 0 deletions swift/llm/template/template/qwen.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class Qwen3Template(ThinkingTemplate):

register_template(QwenTemplateMeta(LLMTemplateType.qwen3_nothinking, default_system=None))

register_template(QwenTemplateMeta(LLMTemplateType.qwen3_coder, default_system=None, agent_template='qwen3_coder'))


class Qwen3RerankerTemplate(Template):
instruction = 'Given a web search query, retrieve relevant passages that answer the query'
Expand Down
4 changes: 2 additions & 2 deletions swift/plugin/agent_template/extra.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
from typing import List, Union
from typing import List, Optional, Union

from .base import BaseAgentTemplate


class ReactGRPOAgentTemplate(BaseAgentTemplate):

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_names = []
tool_descs = []
for tool in tools:
Expand Down
6 changes: 3 additions & 3 deletions swift/plugin/agent_template/glm4.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_toolcall(self, response: str) -> List['Function']:
return super().get_toolcall(response)
return functions

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the method signature is correctly updated to accept an Optional[str] for the system prompt, the implementation of this method currently ignores this parameter. Instead, it uses a hardcoded glm4_system string. This will cause any custom system prompt provided by the user to be discarded when tools are used. To ensure user-provided system prompts are respected, the implementation should be updated to utilize the system parameter, and only fall back to the default glm4_system when the system parameter is None.

tool_descs = []
for tool in tools:
tool = self.unwrap_tool(tool)
Expand Down Expand Up @@ -107,7 +107,7 @@ def get_toolcall(self, response: str) -> List['Function']:
return super().get_toolcall(response)
return functions

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_descs = [
'# Tools\n\nYou may call one or more functions to assist with the user query.\n\n'
'You are provided with function signatures within <tools></tools> XML tags:\n<tools>'
Expand All @@ -119,7 +119,7 @@ def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message
'<arg_value>{arg-value-1}</arg_value>\n<arg_key>{arg-key-2}</arg_key>\n'
'<arg_value>{arg-value-2}</arg_value>\n...\n</tool_call>')
tool_descs = '\n'.join(tool_descs)
if system.strip():
if system is not None and system.strip():
tool_descs += '<|system|>\n' + system.strip()
return tool_descs

Expand Down
8 changes: 5 additions & 3 deletions swift/plugin/agent_template/hermes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import re
from typing import TYPE_CHECKING, List, Tuple, Union
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import json

Expand Down Expand Up @@ -58,8 +58,9 @@ def _format_tool_responses(
res.append(context)
return assistant_content, res

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_descs = [json.dumps(self.wrap_tool(tool), ensure_ascii=False) for tool in tools]
system = system or ''
return f"""{system}

# Tools
Expand Down Expand Up @@ -110,8 +111,9 @@ def _get_tool_calls(self, tool_calls: List[str]):
tool_calls = '\n'.join(tool_calls)
return f'<tool_calls>\n{tool_calls}\n</tool_calls>'

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_descs = [json.dumps(self.wrap_tool(tool), ensure_ascii=False) for tool in tools]
system = system or ''
if system:
system = f'{system}\n\n'
return f"""{system}# Tools
Expand Down
6 changes: 3 additions & 3 deletions swift/plugin/agent_template/llama.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import re
from typing import TYPE_CHECKING, List, Tuple, Union
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import json

Expand Down Expand Up @@ -47,7 +47,7 @@ def _format_tool_responses(
res.append(f'{self.start_token}assistant{self.end_token}\n\n')
return assistant_content, res

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
assert user_message is not None
user_content = user_message['content']
tool_descs = [json.dumps(tool, ensure_ascii=False, indent=4) for tool in tools]
Expand All @@ -59,7 +59,7 @@ def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message

{user_content}""" # noqa
user_message['content'] = new_user_content
return system
return system or ''

def _format_tool_calls(self, tool_call_messages) -> str:
tool_calls = []
Expand Down
5 changes: 3 additions & 2 deletions swift/plugin/agent_template/mistral.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import TYPE_CHECKING, List, Tuple, Union
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import json

Expand Down Expand Up @@ -55,8 +55,9 @@ def _format_tool_responses(
res.append(context)
return assistant_content, res

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_descs = [json.dumps(self.wrap_tool(tool), ensure_ascii=False) for tool in tools]
system = system or ''
return f"""{system}[AVAILABLE_TOOLS]{' '.join(tool_descs)}[/AVAILABLE_TOOLS]"""

def _format_tool_calls(self, tool_call_messages):
Expand Down
14 changes: 9 additions & 5 deletions swift/plugin/agent_template/qwen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
from typing import List, Union
from typing import List, Optional, Union

from .base import AgentKeyword, BaseAgentTemplate

Expand All @@ -24,8 +24,9 @@ def _get_tool_names_descs(self, tools):
f'Parameters: {tool_desc.parameters} {tool_desc.args_format}')
return tool_names, tool_descs

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_names, tool_descs = self._get_tool_names_descs(tools)
system = system or ''
return f"""{system}

# Tools
Expand Down Expand Up @@ -56,8 +57,9 @@ def _get_tool_names_descs(self, tools):
f'输入参数:{tool_desc.parameters} {tool_desc.args_format}')
return tool_names, tool_descs

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_names, tool_descs = self._get_tool_names_descs(tools)
system = system or ''
return f"""{system}

# 工具
Expand All @@ -76,8 +78,9 @@ def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message

class QwenEnParallelAgentTemplate(QwenEnAgentTemplate):

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_names, tool_descs = self._get_tool_names_descs(tools)
system = system or ''
return f"""{system}

# Tools
Expand All @@ -104,8 +107,9 @@ def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message

class QwenZhParallelAgentTemplate(QwenZhAgentTemplate):

def _format_tools(self, tools: List[Union[str, dict]], system: str, user_message=None) -> str:
def _format_tools(self, tools: List[Union[str, dict]], system: Optional[str] = None, user_message=None) -> str:
tool_names, tool_descs = self._get_tool_names_descs(tools)
system = system or ''
return f"""{system}

# 工具
Expand Down
Loading
Loading