Replace --expand-tools-even-if-tool-choice-none with --exclude-tools-when-tool-choice-none for v0.10.0 (#20544)

Signed-off-by: okada <kokuzen@gmail.com>
Signed-off-by: okada shintarou <okada@preferred.jp>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Shintarou Okada
2025-07-24 02:56:36 -07:00
committed by GitHub
co-authored by Harry Mellor
parent 85bda9e7d0
commit 6eca337ce0
4 changed files with 13 additions and 2 deletions
+2
View File
@@ -1646,6 +1646,8 @@ async def init_app_state(
chat_template_content_format=args.chat_template_content_format,
return_tokens_as_token_ids=args.return_tokens_as_token_ids,
enable_auto_tools=args.enable_auto_tool_choice,
exclude_tools_when_tool_choice_none=args.
exclude_tools_when_tool_choice_none,
tool_parser=args.tool_call_parser,
reasoning_parser=args.reasoning_parser,
enable_prompt_tokens_details=args.enable_prompt_tokens_details,
+3
View File
@@ -133,6 +133,9 @@ schema. Example: `[{"type": "text", "text": "Hello world!"}]`"""
"""If specified, API server will add X-Request-Id header to responses.
Caution: this hurts performance at high QPS."""
enable_auto_tool_choice: bool = False
"""If specified, exclude tool definitions in prompts when
tool_choice='none'."""
exclude_tools_when_tool_choice_none: bool = False
"""Enable auto tool choice for supported models. Use `--tool-call-parser`
to specify which parser to use."""
tool_call_parser: Optional[str] = None
+6 -1
View File
@@ -63,6 +63,7 @@ class OpenAIServingChat(OpenAIServing):
return_tokens_as_token_ids: bool = False,
reasoning_parser: str = "",
enable_auto_tools: bool = False,
exclude_tools_when_tool_choice_none: bool = False,
tool_parser: Optional[str] = None,
enable_prompt_tokens_details: bool = False,
enable_force_include_usage: bool = False,
@@ -111,6 +112,8 @@ class OpenAIServingChat(OpenAIServing):
raise TypeError("Error: --enable-auto-tool-choice requires "
f"tool_parser:'{tool_parser}' which has not "
"been registered") from e
self.exclude_tools_when_tool_choice_none = (
exclude_tools_when_tool_choice_none)
self.enable_prompt_tokens_details = enable_prompt_tokens_details
self.enable_force_include_usage = enable_force_include_usage
@@ -174,7 +177,9 @@ class OpenAIServingChat(OpenAIServing):
"--enable-auto-tool-choice and --tool-call-parser to be set"
)
if request.tools is None:
if (request.tools is None
or (request.tool_choice == "none"
and self.exclude_tools_when_tool_choice_none)):
tool_dicts = None
else:
tool_dicts = [tool.model_dump() for tool in request.tools]