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

This commit is contained in:
Chirag Jain
2024-09-27 04:53:17 +05:30
committed by GitHub
parent e2f6f26e86
commit ee2da3e9ef
2 changed files with 72 additions and 1 deletions

View File

@@ -386,7 +386,7 @@ class ChatCompletionRequest(OpenAIBaseModel):
# 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:
if "tool_choice" not in data and data.get("tools"):
data["tool_choice"] = "auto"
# if "tool_choice" is specified -- validation