-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[Frontend] Expand tools even if tool_choice="none" #17177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
ba347cd
5b1b5e7
38eea42
bc031d9
b5e4164
e3733a9
1ffd7f0
e282ebb
b51c7b9
0a0920a
90eabb2
8a45fa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ def __init__( | |
| return_tokens_as_token_ids: bool = False, | ||
| reasoning_parser: str = "", | ||
| enable_auto_tools: bool = False, | ||
| expand_tools_even_if_tool_choice_none: bool = False, | ||
| tool_parser: Optional[str] = None, | ||
| enable_prompt_tokens_details: bool = False, | ||
| ) -> None: | ||
|
|
@@ -108,6 +109,8 @@ def __init__( | |
| raise TypeError("Error: --enable-auto-tool-choice requires " | ||
| f"tool_parser:'{tool_parser}' which has not " | ||
| "been registered") from e | ||
| self.expand_tools_even_if_tool_choice_none = ( | ||
| expand_tools_even_if_tool_choice_none) | ||
|
|
||
| self.enable_prompt_tokens_details = enable_prompt_tokens_details | ||
| self.default_sampling_params = ( | ||
|
|
@@ -172,9 +175,25 @@ async def create_chat_completion( | |
| "--enable-auto-tool-choice and --tool-call-parser to be set" | ||
| ) | ||
|
|
||
| tool_dicts = None if request.tools is None else [ | ||
| tool.model_dump() for tool in request.tools | ||
| ] | ||
| if request.tools is None: | ||
| tool_dicts = None | ||
| elif (request.tool_choice == "none" | ||
| and not self.expand_tools_even_if_tool_choice_none): | ||
| assert request.tools is not None | ||
|
||
| if len(request.tools) > 0: | ||
| logger.warning( | ||
okdshin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "Tools are specified but tool_choice is set to 'none' " | ||
| "and --expand-tools-even-if-tool-choice-none is not " | ||
| "enabled. Tool definitions will be excluded from the " | ||
| "prompt. This behavior will change in vLLM v0.10 where " | ||
| "tool definitions will be included by default even " | ||
| "with tool_choice='none'. To adopt the new behavior " | ||
| "now, use --expand-tools-even-if-tool-choice-none. " | ||
| "To suppress this warning, either remove tools from " | ||
| "the request or set tool_choice to a different value.") | ||
| tool_dicts = None | ||
| else: | ||
| tool_dicts = [tool.model_dump() for tool in request.tools] | ||
|
|
||
| ( | ||
| conversation, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.