Skip to content
Merged
Changes from all commits
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
9 changes: 9 additions & 0 deletions vllm/entrypoints/openai/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,15 @@ def check_tool_usage(cls, data):
'are supported.'
)

# if tool_choice is "required" but the "tools" list is empty,
# override the data to behave like "none" to align with
# OpenAI’s behavior.
if data["tool_choice"] == "required" and isinstance(
data["tools"], list) and len(data["tools"]) == 0:
data["tool_choice"] = "none"
del data["tools"]
return data

# ensure that if "tool_choice" is specified as an object,
# it matches a valid tool
correct_usage_message = 'Correct usage: `{"type": "function",' \
Expand Down