pydantic_to_dict() — langchain Function Reference
Architecture documentation for the pydantic_to_dict() function in _compat.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 30378d77_d906_91d7_ce2d_2e622b24c19f["pydantic_to_dict()"] 75bf479b_1332_0b5c_5710_656c22821d19["_compat.py"] 30378d77_d906_91d7_ce2d_2e622b24c19f -->|defined in| 75bf479b_1332_0b5c_5710_656c22821d19 style 30378d77_d906_91d7_ce2d_2e622b24c19f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/tracers/_compat.py lines 68–80
def pydantic_to_dict(obj: Any, **kwargs: Any) -> dict[str, Any]:
"""Convert any Pydantic model to dict, compatible with both v1 and v2.
Args:
obj: The Pydantic model to convert.
**kwargs: Additional arguments passed to `model_dump`/`dict`.
Returns:
Dictionary representation of the model.
"""
if _RUN_IS_PYDANTIC_V2:
return obj.model_dump(**kwargs) # type: ignore[no-any-return]
return obj.dict(**kwargs) # type: ignore[no-any-return]
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does pydantic_to_dict() do?
pydantic_to_dict() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/_compat.py.
Where is pydantic_to_dict() defined?
pydantic_to_dict() is defined in libs/core/langchain_core/tracers/_compat.py at line 68.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free