_parse_with_schema() — langchain Function Reference
Architecture documentation for the _parse_with_schema() function in structured_output.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b2dc3213_a7ed_bba2_9b4e_51f17afe2086["_parse_with_schema()"] c2936c24_74cd_6911_037b_0f67eebfefee["structured_output.py"] b2dc3213_a7ed_bba2_9b4e_51f17afe2086 -->|defined in| c2936c24_74cd_6911_037b_0f67eebfefee 2e00e1b4_350b_ee3e_5dc5_f7ce23fc8893["parse()"] 2e00e1b4_350b_ee3e_5dc5_f7ce23fc8893 -->|calls| b2dc3213_a7ed_bba2_9b4e_51f17afe2086 0fda5ec1_1f54_5091_4c3c_0202a78dacb3["parse()"] 0fda5ec1_1f54_5091_4c3c_0202a78dacb3 -->|calls| b2dc3213_a7ed_bba2_9b4e_51f17afe2086 style b2dc3213_a7ed_bba2_9b4e_51f17afe2086 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/structured_output.py lines 77–102
def _parse_with_schema(
schema: type[SchemaT] | dict[str, Any], schema_kind: SchemaKind, data: dict[str, Any]
) -> Any:
"""Parse data using for any supported schema type.
Args:
schema: The schema type (Pydantic model, `dataclass`, or `TypedDict`)
schema_kind: One of `'pydantic'`, `'dataclass'`, `'typeddict'`, or
`'json_schema'`
data: The data to parse
Returns:
The parsed instance according to the schema type
Raises:
ValueError: If parsing fails
"""
if schema_kind == "json_schema":
return data
try:
adapter: TypeAdapter[SchemaT] = TypeAdapter(schema)
return adapter.validate_python(data)
except Exception as e:
schema_name = getattr(schema, "__name__", str(schema))
msg = f"Failed to parse data to {schema_name}: {e}"
raise ValueError(msg) from e
Domain
Subdomains
Source
Frequently Asked Questions
What does _parse_with_schema() do?
_parse_with_schema() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/structured_output.py.
Where is _parse_with_schema() defined?
_parse_with_schema() is defined in libs/langchain_v1/langchain/agents/structured_output.py at line 77.
What calls _parse_with_schema()?
_parse_with_schema() is called by 2 function(s): parse, parse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free