Home / Function/ test_function_calling() — langchain Function Reference

test_function_calling() — langchain Function Reference

Architecture documentation for the test_function_calling() function in test_responses_api.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5fa2c5a9_ac31_8b26_6694_cadabb4d86d5["test_function_calling()"]
  992496d5_b7d4_139f_00cf_3e585d851f81["test_responses_api.py"]
  5fa2c5a9_ac31_8b26_6694_cadabb4d86d5 -->|defined in| 992496d5_b7d4_139f_00cf_3e585d851f81
  b0966d53_e5bb_3879_d8d6_00823de68309["_check_response()"]
  5fa2c5a9_ac31_8b26_6694_cadabb4d86d5 -->|calls| b0966d53_e5bb_3879_d8d6_00823de68309
  style 5fa2c5a9_ac31_8b26_6694_cadabb4d86d5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py lines 167–192

def test_function_calling(output_version: Literal["v0", "responses/v1", "v1"]) -> None:
    def multiply(x: int, y: int) -> int:
        """return x * y"""
        return x * y

    llm = ChatOpenAI(model=MODEL_NAME, output_version=output_version)
    bound_llm = llm.bind_tools([multiply, {"type": "web_search_preview"}])
    ai_msg = cast(AIMessage, bound_llm.invoke("whats 5 * 4"))
    assert len(ai_msg.tool_calls) == 1
    assert ai_msg.tool_calls[0]["name"] == "multiply"
    assert set(ai_msg.tool_calls[0]["args"]) == {"x", "y"}

    full: Any = None
    for chunk in bound_llm.stream("whats 5 * 4"):
        assert isinstance(chunk, AIMessageChunk)
        full = chunk if full is None else full + chunk
    assert len(full.tool_calls) == 1
    assert full.tool_calls[0]["name"] == "multiply"
    assert set(full.tool_calls[0]["args"]) == {"x", "y"}

    for msg in [ai_msg, full]:
        assert len(msg.content_blocks) == 1
        assert msg.content_blocks[0]["type"] == "tool_call"

    response = bound_llm.invoke("What was a positive news story from today?")
    _check_response(response)

Domain

Subdomains

Frequently Asked Questions

What does test_function_calling() do?
test_function_calling() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py.
Where is test_function_calling() defined?
test_function_calling() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py at line 167.
What does test_function_calling() call?
test_function_calling() calls 1 function(s): _check_response.

Analyze Your Own Codebase

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

Try Supermodel Free