diff --git a/docs/features/tool_calling.md b/docs/features/tool_calling.md index 70a11d6def566..7b6945cb71c27 100644 --- a/docs/features/tool_calling.md +++ b/docs/features/tool_calling.md @@ -352,10 +352,17 @@ Supported models: * `zai-org/GLM-4.5` * `zai-org/GLM-4.5-Air` * `zai-org/GLM-4.6` -* `zai-org/GLM-4.6-Air` Flags: `--tool-call-parser glm45` +### GLM-4.7 Models (`glm47`) + +Supported models: + +* `zai-org/GLM-4.7` + +Flags: `--tool-call-parser glm47` + ### Qwen3-Coder Models (`qwen3_xml`) Supported models: diff --git a/docs/models/supported_models.md b/docs/models/supported_models.md index 62e42a730e9cb..ffd0681dca7e8 100644 --- a/docs/models/supported_models.md +++ b/docs/models/supported_models.md @@ -387,7 +387,7 @@ th { | `Gemma3nForCausalLM` | Gemma 3n | `google/gemma-3n-E2B-it`, `google/gemma-3n-E4B-it`, etc. | | | | `GlmForCausalLM` | GLM-4 | `zai-org/glm-4-9b-chat-hf`, etc. | ✅︎ | ✅︎ | | `Glm4ForCausalLM` | GLM-4-0414 | `zai-org/GLM-4-32B-0414`, etc. | ✅︎ | ✅︎ | -| `Glm4MoeForCausalLM` | GLM-4.5, GLM-4.6 | `zai-org/GLM-4.5`, etc. | ✅︎ | ✅︎ | +| `Glm4MoeForCausalLM` | GLM-4.5, GLM-4.6, GLM-4.7 | `zai-org/GLM-4.5`, etc. | ✅︎ | ✅︎ | | `GPT2LMHeadModel` | GPT-2 | `gpt2`, `gpt2-xl`, etc. | | ✅︎ | | `GPTBigCodeForCausalLM` | StarCoder, SantaCoder, WizardCoder | `bigcode/starcoder`, `bigcode/gpt_bigcode-santacoder`, `WizardLM/WizardCoder-15B-V1.0`, etc. | ✅︎ | ✅︎ | | `GPTJForCausalLM` | GPT-J | `EleutherAI/gpt-j-6b`, `nomic-ai/gpt4all-j`, etc. | | ✅︎ | diff --git a/vllm/model_executor/models/glm4_moe.py b/vllm/model_executor/models/glm4_moe.py index 541d3b2beff83..6fb09be7c67f2 100644 --- a/vllm/model_executor/models/glm4_moe.py +++ b/vllm/model_executor/models/glm4_moe.py @@ -21,7 +21,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Inference-only GLM-4.5, GLM-4.6 model compatible with HuggingFace weights.""" +"""Inference-only GLM-4.5, GLM-4.6, GLM-4.7 model +compatible with HuggingFace weights.""" import typing from collections.abc import Callable, Iterable diff --git a/vllm/tool_parsers/__init__.py b/vllm/tool_parsers/__init__.py index 181d8bcba9553..ee92727e1c9a4 100644 --- a/vllm/tool_parsers/__init__.py +++ b/vllm/tool_parsers/__init__.py @@ -42,6 +42,10 @@ _TOOL_PARSERS_TO_REGISTER = { "glm4_moe_tool_parser", "Glm4MoeModelToolParser", ), + "glm47": ( + "glm47_moe_tool_parser", + "Glm47MoeModelToolParser", + ), "granite-20b-fc": ( "granite_20b_fc_tool_parser", "Granite20bFCToolParser", diff --git a/vllm/tool_parsers/glm47_moe_tool_parser.py b/vllm/tool_parsers/glm47_moe_tool_parser.py new file mode 100644 index 0000000000000..ae42a640d9413 --- /dev/null +++ b/vllm/tool_parsers/glm47_moe_tool_parser.py @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright contributors to the vLLM project + + +import regex as re + +from vllm.logger import init_logger +from vllm.tokenizers import TokenizerLike +from vllm.tool_parsers.glm4_moe_tool_parser import Glm4MoeModelToolParser + +logger = init_logger(__name__) + + +class Glm47MoeModelToolParser(Glm4MoeModelToolParser): + def __init__(self, tokenizer: TokenizerLike): + super().__init__(tokenizer) + self.func_detail_regex = re.compile( + r"(.*?)(.*?)?", re.DOTALL + ) + self.func_arg_regex = re.compile( + r"(.*?)(?:\\n|\s)*(.*?)", + re.DOTALL, + )