Skip to content
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

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

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
Prev Previous commit
Next Next commit
Apply suggestion from code review
  • Loading branch information
chiragjn authored Sep 19, 2024
commit d2bbf5e69518c648824c21e1d70f9be3c7702fe2
7 changes: 3 additions & 4 deletions vllm/entrypoints/openai/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,11 @@ 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:
if data.get("tools"):
data["tool_choice"] = "auto"
if "tool_choice" not in data and data.get("tools"):
data["tool_choice"] = "auto"

# if "tool_choice" is specified -- validation
elif "tool_choice" in data:
if "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