Home / Function/ test_reasoning() — langchain Function Reference

test_reasoning() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  0430a05b_00c9_4113_f3ec_612c0feb7247["test_reasoning()"]
  992496d5_b7d4_139f_00cf_3e585d851f81["test_responses_api.py"]
  0430a05b_00c9_4113_f3ec_612c0feb7247 -->|defined in| 992496d5_b7d4_139f_00cf_3e585d851f81
  style 0430a05b_00c9_4113_f3ec_612c0feb7247 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_responses_api.py lines 349–371

def test_reasoning(output_version: Literal["v0", "responses/v1", "v1"]) -> None:
    llm = ChatOpenAI(
        model="o4-mini", use_responses_api=True, output_version=output_version
    )
    response = llm.invoke("Hello", reasoning={"effort": "low"})
    assert isinstance(response, AIMessage)

    # Test init params + streaming
    llm = ChatOpenAI(
        model="o4-mini", reasoning={"effort": "low"}, output_version=output_version
    )
    full: BaseMessageChunk | None = None
    for chunk in llm.stream("Hello"):
        assert isinstance(chunk, AIMessageChunk)
        full = chunk if full is None else full + chunk
    assert isinstance(full, AIMessage)

    for msg in [response, full]:
        if output_version == "v0":
            assert msg.additional_kwargs["reasoning"]
        else:
            block_types = [block["type"] for block in msg.content]
            assert block_types == ["reasoning", "text"]

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free