Home / Function/ test_reasoning() — langchain Function Reference

test_reasoning() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  32a9f314_e4f9_be6d_ad8c_912a44666a9b["test_reasoning()"]
  9003580b_9bcf_c959_a278_ba1963301452["test_chat_models.py"]
  32a9f314_e4f9_be6d_ad8c_912a44666a9b -->|defined in| 9003580b_9bcf_c959_a278_ba1963301452
  style 32a9f314_e4f9_be6d_ad8c_912a44666a9b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/mistralai/tests/integration_tests/test_chat_models.py lines 150–171

def test_reasoning() -> None:
    model = ChatMistralAI(model="magistral-medium-latest")  # type: ignore[call-arg]
    input_message = {
        "role": "user",
        "content": "Hello, my name is Bob.",
    }
    full: AIMessageChunk | None = None
    for chunk in model.stream([input_message]):
        assert isinstance(chunk, AIMessageChunk)
        full = chunk if full is None else full + chunk
    assert isinstance(full, AIMessageChunk)
    thinking_blocks = 0
    for i, block in enumerate(full.content):
        if isinstance(block, dict) and block.get("type") == "thinking":
            thinking_blocks += 1
            reasoning_block = full.content_blocks[i]
            assert reasoning_block["type"] == "reasoning"
            assert isinstance(reasoning_block.get("reasoning"), str)
    assert thinking_blocks > 0

    next_message = {"role": "user", "content": "What is my name?"}
    _ = model.invoke([input_message, full, next_message])

Domain

Subdomains

Frequently Asked Questions

What does test_reasoning() do?
test_reasoning() is a function in the langchain codebase, defined in libs/partners/mistralai/tests/integration_tests/test_chat_models.py.
Where is test_reasoning() defined?
test_reasoning() is defined in libs/partners/mistralai/tests/integration_tests/test_chat_models.py at line 150.

Analyze Your Own Codebase

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

Try Supermodel Free