_normalize_schema() — langchain Function Reference
Architecture documentation for the _normalize_schema() function in pydantic_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 31a96103_4c69_062c_4133_8d54d03d7cea["_normalize_schema()"] b22df862_b52d_14dc_cb85_6573258dd27c["pydantic_utils.py"] 31a96103_4c69_062c_4133_8d54d03d7cea -->|defined in| b22df862_b52d_14dc_cb85_6573258dd27c 80bb1e8b_2eb4_f11f_8739_d03f6bd4a5c3["remove_all_none_default()"] 31a96103_4c69_062c_4133_8d54d03d7cea -->|calls| 80bb1e8b_2eb4_f11f_8739_d03f6bd4a5c3 4b6cb995_0278_5df7_b4c7_82cb6b0b8320["replace_all_of_with_ref()"] 31a96103_4c69_062c_4133_8d54d03d7cea -->|calls| 4b6cb995_0278_5df7_b4c7_82cb6b0b8320 308f0879_d0aa_7d08_b310_9c1f1b32e7b1["_remove_enum()"] 31a96103_4c69_062c_4133_8d54d03d7cea -->|calls| 308f0879_d0aa_7d08_b310_9c1f1b32e7b1 ffb01e2b_2f23_d6e1_f1e0_57d9068238b3["_remove_additionalproperties()"] 31a96103_4c69_062c_4133_8d54d03d7cea -->|calls| ffb01e2b_2f23_d6e1_f1e0_57d9068238b3 style 31a96103_4c69_062c_4133_8d54d03d7cea fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/pydantic_utils.py lines 129–150
def _normalize_schema(obj: Any) -> dict[str, Any]:
"""Generate a schema and normalize it.
This will collapse single element allOfs into $ref.
For example,
'obj': {'allOf': [{'$ref': '#/$defs/obj'}]
to:
'obj': {'$ref': '#/$defs/obj'}
Args:
obj: The object to generate the schema for
"""
data = obj.model_json_schema() if isinstance(obj, BaseModel) else obj
remove_all_none_default(data)
replace_all_of_with_ref(data)
_remove_enum(data)
_remove_additionalproperties(data)
return data
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does _normalize_schema() do?
_normalize_schema() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/pydantic_utils.py.
Where is _normalize_schema() defined?
_normalize_schema() is defined in libs/core/tests/unit_tests/pydantic_utils.py at line 129.
What does _normalize_schema() call?
_normalize_schema() calls 4 function(s): _remove_additionalproperties, _remove_enum, remove_all_none_default, replace_all_of_with_ref.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free