Home / Function/ test_openai_structured_output() — langchain Function Reference

test_openai_structured_output() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  97d03a2c_c270_ea80_6fb5_ad45496789a6["test_openai_structured_output()"]
  bd382a4e_442c_13ae_530c_6e34bc43623d["test_base.py"]
  97d03a2c_c270_ea80_6fb5_ad45496789a6 -->|defined in| bd382a4e_442c_13ae_530c_6e34bc43623d
  style 97d03a2c_c270_ea80_6fb5_ad45496789a6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 624–635

def test_openai_structured_output(model: str) -> None:
    class MyModel(BaseModel):
        """A Person"""

        name: str
        age: int

    llm = ChatOpenAI(model=model).with_structured_output(MyModel)
    result = llm.invoke("I'm a 27 year old named Erick")
    assert isinstance(result, MyModel)
    assert result.name == "Erick"
    assert result.age == 27

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free