test_tool_choice_bool() — langchain Function Reference
Architecture documentation for the test_tool_choice_bool() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f1b1748c_3b09_a04f_066f_1eecc9cdf7da["test_tool_choice_bool()"] ec975712_a998_0a1f_0930_22940fc39a1e["test_chat_models.py"] f1b1748c_3b09_a04f_066f_1eecc9cdf7da -->|defined in| ec975712_a998_0a1f_0930_22940fc39a1e style f1b1748c_3b09_a04f_066f_1eecc9cdf7da fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/fireworks/tests/integration_tests/test_chat_models.py lines 22–57
def test_tool_choice_bool(strict: bool | None) -> None: # noqa: FBT001
"""Test that tool choice is respected with different strict values."""
llm = ChatFireworks(model="accounts/fireworks/models/kimi-k2-instruct-0905")
class MyTool(BaseModel):
name: str
age: int
kwargs = {"tool_choice": True}
if strict is not None:
kwargs["strict"] = strict
with_tool = llm.bind_tools([MyTool], **kwargs)
# Verify that strict is correctly set in the tool definition
assert hasattr(with_tool, "kwargs")
tools = with_tool.kwargs.get("tools", [])
assert len(tools) == 1
tool_def = tools[0]
assert "function" in tool_def
if strict is None:
assert "strict" not in tool_def["function"]
else:
assert tool_def["function"].get("strict") is strict
resp = with_tool.invoke("Who was the 27 year old named Erick?")
assert isinstance(resp, AIMessage)
assert resp.content == "" # should just be tool call
tool_calls = resp.additional_kwargs["tool_calls"]
assert len(tool_calls) == 1
tool_call = tool_calls[0]
assert tool_call["function"]["name"] == "MyTool"
assert json.loads(tool_call["function"]["arguments"]) == {
"age": 27,
"name": "Erick",
}
assert tool_call["type"] == "function"
Domain
Subdomains
Source
Frequently Asked Questions
What does test_tool_choice_bool() do?
test_tool_choice_bool() is a function in the langchain codebase, defined in libs/partners/fireworks/tests/integration_tests/test_chat_models.py.
Where is test_tool_choice_bool() defined?
test_tool_choice_bool() is defined in libs/partners/fireworks/tests/integration_tests/test_chat_models.py at line 22.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free