Home / Function/ test_response_format() — langchain Function Reference

test_response_format() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  d1503436_1a92_ccf7_a3a2_f10fd280c838["test_response_format()"]
  f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"]
  d1503436_1a92_ccf7_a3a2_f10fd280c838 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f
  style d1503436_1a92_ccf7_a3a2_f10fd280c838 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 727–740

def test_response_format(schema: dict | type) -> None:
    model = ChatAnthropic(
        model="claude-sonnet-4-5",  # type: ignore[call-arg]
    )
    query = "Chester (a.k.a. Chet) is 100 years old."

    response = model.invoke(query, response_format=schema)
    parsed = json.loads(response.text)
    if isinstance(schema, type) and issubclass(schema, BaseModel):
        schema.model_validate(parsed)
    else:
        assert isinstance(parsed, dict)
        assert parsed["name"]
        assert parsed["age"]

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free