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 1dd6c118_5a65_f062_71d3_f7b1ac76b8e6["test_tool_choice_bool()"] af57ae60_607e_c138_9ab0_fb8bb1c5916a["test_chat_models.py"] 1dd6c118_5a65_f062_71d3_f7b1ac76b8e6 -->|defined in| af57ae60_607e_c138_9ab0_fb8bb1c5916a style 1dd6c118_5a65_f062_71d3_f7b1ac76b8e6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/groq/tests/integration_tests/test_chat_models.py lines 434–455
def test_tool_choice_bool() -> None:
"""Test that tool choice is respected just passing in True."""
llm = ChatGroq(model=DEFAULT_MODEL_NAME)
class MyTool(BaseModel):
name: str
age: int
with_tool = llm.bind_tools([MyTool], tool_choice=True)
resp = with_tool.invoke("Who was the 27 year old named Erick? Use the tool.")
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/groq/tests/integration_tests/test_chat_models.py.
Where is test_tool_choice_bool() defined?
test_tool_choice_bool() is defined in libs/partners/groq/tests/integration_tests/test_chat_models.py at line 434.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free