Home / Function/ test_structured_outputs_parser() — langchain Function Reference

test_structured_outputs_parser() — langchain Function Reference

Architecture documentation for the test_structured_outputs_parser() function in test_base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  58286bb9_9064_7881_8f03_670eba1cc231["test_structured_outputs_parser()"]
  48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"]
  58286bb9_9064_7881_8f03_670eba1cc231 -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5
  style 58286bb9_9064_7881_8f03_670eba1cc231 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 1354–1369

def test_structured_outputs_parser() -> None:
    parsed_response = GenerateUsername(name="alice", hair_color="black")
    llm_output = ChatGeneration(
        message=AIMessage(
            content='{"name": "alice", "hair_color": "black"}',
            additional_kwargs={"parsed": parsed_response},
        )
    )
    output_parser = RunnableLambda(
        partial(_oai_structured_outputs_parser, schema=GenerateUsername)
    )
    serialized = dumps(llm_output)
    deserialized = loads(serialized, allowed_objects=[ChatGeneration, AIMessage])
    assert isinstance(deserialized, ChatGeneration)
    result = output_parser.invoke(cast(AIMessage, deserialized.message))
    assert result == parsed_response

Domain

Subdomains

Frequently Asked Questions

What does test_structured_outputs_parser() do?
test_structured_outputs_parser() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is test_structured_outputs_parser() defined?
test_structured_outputs_parser() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 1354.

Analyze Your Own Codebase

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

Try Supermodel Free