test_nested_structured_output_strict() — langchain Function Reference
Architecture documentation for the test_nested_structured_output_strict() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a0fdfbcf_c6c5_15d5_7712_de97312ac87e["test_nested_structured_output_strict()"] bd382a4e_442c_13ae_530c_6e34bc43623d["test_base.py"] a0fdfbcf_c6c5_15d5_7712_de97312ac87e -->|defined in| bd382a4e_442c_13ae_530c_6e34bc43623d style a0fdfbcf_c6c5_15d5_7712_de97312ac87e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 817–848
def test_nested_structured_output_strict(
model: str, method: Literal["json_schema"], use_responses_api: bool
) -> None:
"""Test to verify structured output with strict=True for nested object."""
from typing import TypedDict
llm = ChatOpenAI(model=model, temperature=0, use_responses_api=use_responses_api)
class SelfEvaluation(TypedDict):
score: int
text: str
class JokeWithEvaluation(TypedDict):
"""Joke to tell user."""
setup: str
punchline: str
self_evaluation: SelfEvaluation
# Schema
chat = llm.with_structured_output(JokeWithEvaluation, method=method, strict=True)
result = chat.invoke("Tell me a joke about cats.")
assert isinstance(result, dict)
assert set(result.keys()) == {"setup", "punchline", "self_evaluation"}
assert set(result["self_evaluation"].keys()) == {"score", "text"}
for chunk in chat.stream("Tell me a joke about cats."):
assert isinstance(chunk, dict)
assert isinstance(chunk, dict) # for mypy
assert set(chunk.keys()) == {"setup", "punchline", "self_evaluation"}
assert set(chunk["self_evaluation"].keys()) == {"score", "text"}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_nested_structured_output_strict() do?
test_nested_structured_output_strict() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py.
Where is test_nested_structured_output_strict() defined?
test_nested_structured_output_strict() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py at line 817.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free