LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coreutilspydantic
    Module●Since v0.1

    pydantic

    Utilities for pydantic.

    Attributes

    Functions

    Type Aliases

    View source on GitHub
    attribute
    PYDANTIC_VERSION
    attribute
    PYDANTIC_MAJOR_VERSION
    attribute
    PYDANTIC_MINOR_VERSION
    attribute
    IS_PYDANTIC_V1: bool
    attribute
    IS_PYDANTIC_V2: bool
    attribute
    TBaseModel
    attribute
    NO_DEFAULT
    function
    is_pydantic_v1_subclass
    function
    is_pydantic_v2_subclass
    function
    is_basemodel_subclass
    function
    is_basemodel_instance
    function
    pre_init
    function
    get_fields
    function
    model_json_schema
    function
    model_validate
    function
    create_model
    function
    create_model_v2
    deprecatedfunction
    get_pydantic_major_version
    typeAlias
    PydanticBaseModel
    typeAlias
    TypeBaseModel: type[BaseModel] | type[BaseModelV1]

    Check if the given class is Pydantic v1-like.

    Check if the given class is Pydantic v2-like.

    Check if the given class is a subclass of Pydantic BaseModel.

    Check if the given class is a subclass of any of the following:

    • pydantic.BaseModel in Pydantic 2.x
    • pydantic.v1.BaseModel in Pydantic 2.x

    Check if the given class is an instance of Pydantic BaseModel.

    Check if the given class is an instance of any of the following:

    • pydantic.BaseModel in Pydantic 2.x
    • pydantic.v1.BaseModel in Pydantic 2.x

    Decorator to run a function before model initialization.

    Return the field names of a Pydantic model.

    Return the JSON schema of a Pydantic model class of either major version.

    Dispatches to the correct method for Pydantic v1 (schema) or v2 (model_json_schema), so callers holding a TypeBaseModel don't have to branch on the model's version themselves.

    Validate obj against a Pydantic model class of either major version.

    Dispatches to the correct method for Pydantic v1 (parse_obj) or v2 (model_validate), so callers holding a TypeBaseModel don't have to branch on the model's version themselves.

    Create a Pydantic model with the given field definitions.

    Please use create_model_v2 instead of this function.

    Create a Pydantic model with the given field definitions.

    Warning

    Do not use outside of langchain packages. This API is subject to change at any time.

    DEPRECATED - Get the major version of Pydantic.

    Use PYDANTIC_VERSION.major instead.