mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
fix(anthropic): drop orphan tool_choice when tools array is empty (#25477)
This commit is contained in:
parent
cae8613660
commit
5aa56f318c
1 changed files with 5 additions and 0 deletions
|
|
@ -1081,6 +1081,11 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
|
|||
non_default_params=non_default_params, optional_params=optional_params
|
||||
)
|
||||
|
||||
# Anthropic requires tools to be specified if tool_choice is specified.
|
||||
# If tools were stripped out (e.g. intercepted), we must also remove tool_choice.
|
||||
if "tool_choice" in optional_params and not optional_params.get("tools"):
|
||||
optional_params.pop("tool_choice", None)
|
||||
|
||||
return optional_params
|
||||
|
||||
def _create_json_tool_call_for_response_format(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue