anthropic[patch]: support parallel_tool_calls (#29257)

Need to:
- Update docs
- Decide if this is an explicit kwarg of bind_tools
- Decide if this should be in standard test with flag for supporting
This commit is contained in:
ccurme
2025-01-17 14:41:41 -05:00
committed by GitHub
parent 628145b172
commit c616b445f2
3 changed files with 49 additions and 0 deletions

View File

@@ -630,6 +630,18 @@ def test_bind_tools_tool_choice() -> None:
assert not msg.tool_calls
def test_disable_parallel_tool_calling() -> None:
llm = ChatOpenAI(model="gpt-4o-mini")
llm_with_tools = llm.bind_tools([GenerateUsername], parallel_tool_calls=False)
result = llm_with_tools.invoke(
"Use the GenerateUsername tool to generate user names for:\n\n"
"Sally with green hair\n"
"Bob with blue hair"
)
assert isinstance(result, AIMessage)
assert len(result.tool_calls) == 1
@pytest.mark.parametrize("model", ["gpt-4o-mini", "o1"])
def test_openai_structured_output(model: str) -> None:
class MyModel(BaseModel):