[Fix] glm47: Disable tool grammar for tool_choice="none" (#41233)
Co-authored-by: Po-Han Huang (NVIDIA) <53919306+nvpohanh@users.noreply.github.com> Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com> Co-authored-by: Po-Han Huang <pohanh@nvidia.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Po-Han Huang
Xinyuan Tong
Po-Han Huang
Claude Opus 5.5
parent
1897575ce1
commit
79ed13fc2c
@@ -1378,18 +1378,19 @@ class OpenAIServingChat(OpenAIServingBase):
|
||||
tool_call_constraint = None
|
||||
|
||||
effective_tools = self._effective_tools(request)
|
||||
# Only tool-bearing requests get the full-assistant EBNF: its terminal
|
||||
# state finishes a request even under ignore_eos.
|
||||
# A grammar reaching its terminal state ends generation regardless of
|
||||
# `ignore_eos`, so only install it when the request allows tool calls.
|
||||
glm_constraint = (
|
||||
self.tool_call_parser == "glm47"
|
||||
and bool(effective_tools)
|
||||
and request.tool_choice != "none"
|
||||
and not any(tool.function.strict for tool in effective_tools)
|
||||
)
|
||||
if glm_constraint:
|
||||
enable_thinking = (request.chat_template_kwargs or {}).get(
|
||||
"enable_thinking"
|
||||
)
|
||||
parser = FunctionCallParser(request.tools or [], self.tool_call_parser)
|
||||
parser = FunctionCallParser(effective_tools, self.tool_call_parser)
|
||||
tool_call_constraint = parser.get_structure_constraint(
|
||||
request.tool_choice,
|
||||
parallel_tool_calls=request.parallel_tool_calls,
|
||||
|
||||
Reference in New Issue
Block a user