Home / Function/ test__format_output() — langchain Function Reference

test__format_output() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  684bcb75_9723_dcda_40a4_64de42c45cce["test__format_output()"]
  18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"]
  684bcb75_9723_dcda_40a4_64de42c45cce -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311
  style 684bcb75_9723_dcda_40a4_64de42c45cce fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 197–220

def test__format_output() -> None:
    anthropic_msg = Message(
        id="foo",
        content=[TextBlock(type="text", text="bar")],
        model="baz",
        role="assistant",
        stop_reason=None,
        stop_sequence=None,
        usage=Usage(input_tokens=2, output_tokens=1),
        type="message",
    )
    expected = AIMessage(  # type: ignore[misc]
        "bar",
        usage_metadata={
            "input_tokens": 2,
            "output_tokens": 1,
            "total_tokens": 3,
            "input_token_details": {},
        },
        response_metadata={"model_provider": "anthropic"},
    )
    llm = ChatAnthropic(model=MODEL_NAME, anthropic_api_key="test")  # type: ignore[call-arg, call-arg]
    actual = llm._format_output(anthropic_msg)
    assert actual.generations[0].message == expected

Domain

Subdomains

Frequently Asked Questions

What does test__format_output() do?
test__format_output() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test__format_output() defined?
test__format_output() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 197.

Analyze Your Own Codebase

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

Try Supermodel Free