fireworks[patch]: allow tool_choice with multiple tools (#26999)

https://docs.fireworks.ai/api-reference/post-chatcompletions
This commit is contained in:
Bagatur 2024-09-30 11:28:43 -07:00 committed by GitHub
parent c7120d87dd
commit 0078493a80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -721,19 +721,6 @@ class ChatFireworks(BaseChatModel):
tool_choice not in ("auto", "any", "none")
):
tool_choice = {"type": "function", "function": {"name": tool_choice}}
if isinstance(tool_choice, dict) and (len(formatted_tools) != 1):
raise ValueError(
"When specifying `tool_choice`, you must provide exactly one "
f"tool. Received {len(formatted_tools)} tools."
)
if isinstance(tool_choice, dict) and (
formatted_tools[0]["function"]["name"]
!= tool_choice["function"]["name"]
):
raise ValueError(
f"Tool choice {tool_choice} was specified, but the only "
f"provided tool was {formatted_tools[0]['function']['name']}."
)
if isinstance(tool_choice, bool):
if len(tools) > 1:
raise ValueError(