Home / File/ pydantic.py — langchain Source File

pydantic.py — langchain Source File

Architecture documentation for pydantic.py, a python file in the langchain codebase. 17 imports, 3 dependents.

File python Observability TelemetryUtilities 17 imports 3 dependents 17 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  892b1d9f_bb87_0364_19af_71382204e430["pydantic.py"]
  589b2e2f_c593_ed0a_7906_df4ca371d542["inspect"]
  892b1d9f_bb87_0364_19af_71382204e430 --> 589b2e2f_c593_ed0a_7906_df4ca371d542
  03f80c39_eacc_544b_ec23_773c11b2e950["textwrap"]
  892b1d9f_bb87_0364_19af_71382204e430 --> 03f80c39_eacc_544b_ec23_773c11b2e950
  f3365e3c_fb7a_bb9a_bc79_059b06cb7024["warnings"]
  892b1d9f_bb87_0364_19af_71382204e430 --> f3365e3c_fb7a_bb9a_bc79_059b06cb7024
  be45a0bb_0276_f8f1_f985_55cddb92c224["contextlib"]
  892b1d9f_bb87_0364_19af_71382204e430 --> be45a0bb_0276_f8f1_f985_55cddb92c224
  f46e1812_79f8_1bd0_7815_2ba4471dc470["functools"]
  892b1d9f_bb87_0364_19af_71382204e430 --> f46e1812_79f8_1bd0_7815_2ba4471dc470
  8322cf04_5861_9d4a_4ee9_a22829f66390["types"]
  892b1d9f_bb87_0364_19af_71382204e430 --> 8322cf04_5861_9d4a_4ee9_a22829f66390
  feec1ec4_6917_867b_d228_b134d0ff8099["typing"]
  892b1d9f_bb87_0364_19af_71382204e430 --> feec1ec4_6917_867b_d228_b134d0ff8099
  892b1d9f_bb87_0364_19af_71382204e430["pydantic.py"]
  892b1d9f_bb87_0364_19af_71382204e430 --> 892b1d9f_bb87_0364_19af_71382204e430
  d912fac6_18fe_9064_7414_d41f86abc6b6["packaging"]
  892b1d9f_bb87_0364_19af_71382204e430 --> d912fac6_18fe_9064_7414_d41f86abc6b6
  c2f6fa80_5d24_efc6_4956_e42101ac1fc3["create_model"]
  892b1d9f_bb87_0364_19af_71382204e430 --> c2f6fa80_5d24_efc6_4956_e42101ac1fc3
  c3791a0f_5ecc_4bfa_83f8_f7f09c77c118["pydantic.fields"]
  892b1d9f_bb87_0364_19af_71382204e430 --> c3791a0f_5ecc_4bfa_83f8_f7f09c77c118
  c3f54d8b_937c_e233_9439_f07565568a57["pydantic.json_schema"]
  892b1d9f_bb87_0364_19af_71382204e430 --> c3f54d8b_937c_e233_9439_f07565568a57
  c152ff20_1e21_d466_99bf_a0481a5136a6["pydantic.v1"]
  892b1d9f_bb87_0364_19af_71382204e430 --> c152ff20_1e21_d466_99bf_a0481a5136a6
  f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"]
  892b1d9f_bb87_0364_19af_71382204e430 --> f85fae70_1011_eaec_151c_4083140ae9e5
  2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"]
  892b1d9f_bb87_0364_19af_71382204e430 --> 2bf6d401_816d_d011_3b05_a6114f55ff58
  style 892b1d9f_bb87_0364_19af_71382204e430 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Utilities for pydantic."""

from __future__ import annotations

import inspect
import textwrap
import warnings
from contextlib import nullcontext
from functools import lru_cache, wraps
from types import GenericAlias
from typing import (
    TYPE_CHECKING,
    Any,
    TypeVar,
    cast,
    overload,
)

import pydantic
from packaging import version

# root_validator is deprecated but we need it for backward compatibility of @pre_init
from pydantic import (  # type: ignore[deprecated]
    BaseModel,
    ConfigDict,
    Field,
    PydanticDeprecationWarning,
    RootModel,
    root_validator,
)
from pydantic import (
    create_model as _create_model_base,
)
from pydantic.fields import FieldInfo as FieldInfoV2
from pydantic.json_schema import (
    DEFAULT_REF_TEMPLATE,
    GenerateJsonSchema,
    JsonSchemaMode,
    JsonSchemaValue,
)
from pydantic.v1 import BaseModel as BaseModelV1
from pydantic.v1 import create_model as create_model_v1
from typing_extensions import deprecated, override

if TYPE_CHECKING:
    from collections.abc import Callable

    from pydantic.v1.fields import ModelField
    from pydantic_core import core_schema

PYDANTIC_VERSION = version.parse(pydantic.__version__)


@deprecated("Use PYDANTIC_VERSION.major instead.")
def get_pydantic_major_version() -> int:
    """DEPRECATED - Get the major version of Pydantic.

    Use `PYDANTIC_VERSION.major` instead.

    Returns:
// ... (525 more lines)

Domain

Subdomains

Dependencies

  • collections.abc
  • contextlib
  • create_model
  • functools
  • inspect
  • packaging
  • pydantic.fields
  • pydantic.json_schema
  • pydantic.py
  • pydantic.v1
  • pydantic.v1.fields
  • pydantic_core
  • textwrap
  • types
  • typing
  • typing_extensions
  • warnings

Frequently Asked Questions

What does pydantic.py do?
pydantic.py is a source file in the langchain codebase, written in python. It belongs to the Observability domain, TelemetryUtilities subdomain.
What functions are defined in pydantic.py?
pydantic.py defines 17 function(s): _create_model_cached, _create_root_model, _create_root_model_cached, _create_subset_model, _create_subset_model_v1, _create_subset_model_v2, _remap_field_definitions, collections, create_model, create_model_v2, and 7 more.
What does pydantic.py depend on?
pydantic.py imports 17 module(s): collections.abc, contextlib, create_model, functools, inspect, packaging, pydantic.fields, pydantic.json_schema, and 9 more.
What files import pydantic.py?
pydantic.py is imported by 3 file(s): function_calling.py, pydantic.py, utils.py.
Where is pydantic.py in the architecture?
pydantic.py is located at libs/core/langchain_core/utils/pydantic.py (domain: Observability, subdomain: TelemetryUtilities, directory: libs/core/langchain_core/utils).

Analyze Your Own Codebase

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

Try Supermodel Free