Home / Function/ test_structured_output_json_schema() — langchain Function Reference

test_structured_output_json_schema() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  3a78e7f5_a507_e769_82e0_7d81284eced3["test_structured_output_json_schema()"]
  9003580b_9bcf_c959_a278_ba1963301452["test_chat_models.py"]
  3a78e7f5_a507_e769_82e0_7d81284eced3 -->|defined in| 9003580b_9bcf_c959_a278_ba1963301452
  9e461ed6_e4e5_e9f4_e22d_4d9ed4b401b3["_check_parsed_result()"]
  3a78e7f5_a507_e769_82e0_7d81284eced3 -->|calls| 9e461ed6_e4e5_e9f4_e22d_4d9ed4b401b3
  style 3a78e7f5_a507_e769_82e0_7d81284eced3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/mistralai/tests/integration_tests/test_chat_models.py lines 72–89

def test_structured_output_json_schema(schema: Any) -> None:
    llm = ChatMistralAI(model="ministral-8b-latest")  # type: ignore[call-arg]
    structured_llm = llm.with_structured_output(schema, method="json_schema")

    messages = [
        {"role": "system", "content": "Extract the book's information."},
        {
            "role": "user",
            "content": "I recently read 'To Kill a Mockingbird' by Harper Lee.",
        },
    ]
    # Test invoke
    result = structured_llm.invoke(messages)
    _check_parsed_result(result, schema)

    # Test stream
    for chunk in structured_llm.stream(messages):
        _check_parsed_result(chunk, schema)

Domain

Subdomains

Frequently Asked Questions

What does test_structured_output_json_schema() do?
test_structured_output_json_schema() is a function in the langchain codebase, defined in libs/partners/mistralai/tests/integration_tests/test_chat_models.py.
Where is test_structured_output_json_schema() defined?
test_structured_output_json_schema() is defined in libs/partners/mistralai/tests/integration_tests/test_chat_models.py at line 72.
What does test_structured_output_json_schema() call?
test_structured_output_json_schema() calls 1 function(s): _check_parsed_result.

Analyze Your Own Codebase

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

Try Supermodel Free