Home / Function/ test_bind_tools_tool_choice() — langchain Function Reference

test_bind_tools_tool_choice() — langchain Function Reference

Architecture documentation for the test_bind_tools_tool_choice() function in test_base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b7d1dbbc_abfc_6dbc_cb49_583b0240cda5["test_bind_tools_tool_choice()"]
  bd382a4e_442c_13ae_530c_6e34bc43623d["test_base.py"]
  b7d1dbbc_abfc_6dbc_cb49_583b0240cda5 -->|defined in| bd382a4e_442c_13ae_530c_6e34bc43623d
  style b7d1dbbc_abfc_6dbc_cb49_583b0240cda5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 594–608

def test_bind_tools_tool_choice(use_responses_api: bool) -> None:
    """Test passing in manually construct tool call message."""
    llm = ChatOpenAI(
        model="gpt-5-nano", temperature=0, use_responses_api=use_responses_api
    )
    for tool_choice in ("any", "required"):
        llm_with_tools = llm.bind_tools(
            tools=[GenerateUsername, MakeASandwich], tool_choice=tool_choice
        )
        msg = cast(AIMessage, llm_with_tools.invoke("how are you"))
        assert msg.tool_calls

    llm_with_tools = llm.bind_tools(tools=[GenerateUsername, MakeASandwich])
    msg = cast(AIMessage, llm_with_tools.invoke("how are you"))
    assert not msg.tool_calls

Domain

Subdomains

Frequently Asked Questions

What does test_bind_tools_tool_choice() do?
test_bind_tools_tool_choice() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py.
Where is test_bind_tools_tool_choice() defined?
test_bind_tools_tool_choice() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py at line 594.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free