Unverified Commit 7aaa2bd5 authored by Guillaume Calmettes's avatar Guillaume Calmettes Committed by GitHub
Browse files

[Bugfix] ensure tool_choice is popped when `tool_choice:null` is passed in json payload (#19679)


Signed-off-by: default avatarGuillaume Calmettes <gcalmettes@scaleway.com>
parent 2f5c14de
...@@ -841,7 +841,7 @@ class ChatCompletionRequest(OpenAIBaseModel): ...@@ -841,7 +841,7 @@ class ChatCompletionRequest(OpenAIBaseModel):
return data return data
# if "tool_choice" is specified -- validation # if "tool_choice" is specified -- validation
if "tool_choice" in data: if "tool_choice" in data and data["tool_choice"] is not None:
# ensure that if "tool choice" is specified, tools are present # ensure that if "tool choice" is specified, tools are present
if "tools" not in data or data["tools"] is None: if "tools" not in data or data["tools"] is None:
...@@ -853,7 +853,7 @@ class ChatCompletionRequest(OpenAIBaseModel): ...@@ -853,7 +853,7 @@ class ChatCompletionRequest(OpenAIBaseModel):
if data["tool_choice"] not in [ if data["tool_choice"] not in [
"auto", "required" "auto", "required"
] and not isinstance(data["tool_choice"], dict): ] and not isinstance(data["tool_choice"], dict):
raise NotImplementedError( raise ValueError(
f'Invalid value for `tool_choice`: {data["tool_choice"]}! '\ f'Invalid value for `tool_choice`: {data["tool_choice"]}! '\
'Only named tools, "none", "auto" or "required" '\ 'Only named tools, "none", "auto" or "required" '\
'are supported.' 'are supported.'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment