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-coreutilspydanticcreate_model_v2
    Functionā—Since v0.3

    create_model_v2

    Copy
    create_model_v2(
      model_name: str,
      *,
      module_name: str | None = None,
      field_definitions: 
    View source on GitHub
    dict
    [
    str
    ,
    Any
    ]
    |
    None
    =
    None
    ,
    root
    :
    Any
    |
    None
    =
    None
    )
    ->
    type
    [
    BaseModel
    ]

    Parameters

    NameTypeDescription
    model_name*str

    The name of the model.

    module_namestr | None
    Default:None

    The name of the module where the model is defined.

    This is used by Pydantic to resolve any forward references.

    field_definitionsdict[str, Any] | None
    Default:None
    rootAny | None
    Default:None

    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.

    The field definitions for the model.

    Type for a root model (RootModel)