Home / Function/ test_structured_output_strict() — langchain Function Reference

test_structured_output_strict() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 1156–1171

def test_structured_output_strict(
    method: Literal["function_calling", "json_schema"], strict: bool | None
) -> None:
    """Test to verify structured output with strict=True."""

    llm = ChatOpenAI(model="gpt-4o-2024-08-06")

    class Joke(BaseModel):
        """Joke to tell user."""

        setup: str = Field(description="question to set up a joke")
        punchline: str = Field(description="answer to resolve the joke")

    llm.with_structured_output(Joke, method=method, strict=strict)
    # Schema
    llm.with_structured_output(Joke.model_json_schema(), method=method, strict=strict)

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free