Skip to content

fix validation: Only set tool_choice auto if at least one tool is provided #8568

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

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions vllm/entrypoints/openai/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,12 @@ def check_tool_usage(cls, data):

# if "tool_choice" is not specified but tools are provided,
# default to "auto" tool_choice
if "tool_choice" not in data and "tools" in data:
data["tool_choice"] = "auto"
if "tool_choice" not in data:
if data.get("tools"):
data["tool_choice"] = "auto"

# if "tool_choice" is specified -- validation
if "tool_choice" in data:
elif "tool_choice" in data:

# ensure that if "tool choice" is specified, tools are present
if "tools" not in data or data["tools"] is None:
Expand Down
Loading