Unverified Commit 7cdba98e authored by ShiJie Zhong's avatar ShiJie Zhong Committed by GitHub
Browse files

[BugFix] Support tool_choice=none in the Anthropic API (#35835)


Signed-off-by: default avatarZhongsJie <zhongsjie@gmail.com>
Co-authored-by: default avatarChauncey <chaunceyjiang@gmail.com>
parent 3c85cd9d
...@@ -77,7 +77,7 @@ class AnthropicTool(BaseModel): ...@@ -77,7 +77,7 @@ class AnthropicTool(BaseModel):
class AnthropicToolChoice(BaseModel): class AnthropicToolChoice(BaseModel):
"""Tool Choice definition""" """Tool Choice definition"""
type: Literal["auto", "any", "tool"] type: Literal["auto", "any", "tool", "none"]
name: str | None = None name: str | None = None
@model_validator(mode="after") @model_validator(mode="after")
......
...@@ -349,6 +349,8 @@ class AnthropicServingMessages(OpenAIServingChat): ...@@ -349,6 +349,8 @@ class AnthropicServingMessages(OpenAIServingChat):
req.tool_choice = "auto" req.tool_choice = "auto"
elif tool_choice_type == "any": elif tool_choice_type == "any":
req.tool_choice = "required" req.tool_choice = "required"
elif tool_choice_type == "none":
req.tool_choice = "none"
elif tool_choice_type == "tool": elif tool_choice_type == "tool":
req.tool_choice = ChatCompletionNamedToolChoiceParam.model_validate( req.tool_choice = ChatCompletionNamedToolChoiceParam.model_validate(
{ {
......
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