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-corepromptsbase
    Module●Since v0.1

    base

    Base class for prompt templates.

    Attributes

    Functions

    Classes

    View source on GitHub
    attribute
    FormatOutputType
    function
    deprecated
    function
    create_message
    function
    dumpd
    function
    ensure_config
    function
    create_model_v2
    function
    format_document
    function
    aformat_document
    class
    ErrorCode
    class
    BaseOutputParser
    class
    ChatPromptValueConcrete
    class
    PromptValue
    class
    StringPromptValue
    class
    RunnableConfig
    class
    RunnableSerializable
    class
    Document
    class
    BasePromptTemplate

    Decorator to mark a function, a class, or a property as deprecated.

    When deprecating a classmethod, a staticmethod, or a property, the @deprecated decorator should go under @classmethod and @staticmethod (i.e., deprecated should directly decorate the underlying callable), but over @property.

    When deprecating a class C intended to be used as a base class in a multiple inheritance hierarchy, C must define an __init__ method (if C instead inherited its __init__ from its own base class, then @deprecated would mess up __init__ inheritance when installing its own (deprecation-emitting) C.__init__).

    Parameters are the same as for warn_deprecated, except that obj_type defaults to 'class' if decorating a class, 'attribute' if decorating a property, and 'function' otherwise.

    Create a message with a link to the LangChain troubleshooting guide.

    Return a dict representation of an object.

    Ensure that a config is a dict with all keys present.

    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.

    Format a document into a string based on a prompt template.

    First, this pulls information from the document from two sources:

    1. page_content: This takes the information from the document.page_content and assigns it to a variable named page_content.
    2. metadata: This takes information from document.metadata and assigns it to variables of the same name.

    Those variables are then passed into the prompt to produce a formatted string.

    Async format a document into a string based on a prompt template.

    First, this pulls information from the document from two sources:

    1. page_content: This takes the information from the document.page_content and assigns it to a variable named page_content.
    2. metadata: This takes information from document.metadata and assigns it to variables of the same name.

    Those variables are then passed into the prompt to produce a formatted string.

    Error codes.

    Base class to parse the output of an LLM call.

    Output parsers help structure language model responses.

    Chat prompt value which explicitly lists out the message types it accepts.

    For use in external schemas.

    Base abstract class for inputs to any language model.

    PromptValues can be converted to both LLM (pure text-generation) inputs and chat model inputs.

    String prompt value.

    Runnable that can be serialized to JSON.

    Class for storing a piece of text and associated metadata.

    Note

    Document is for retrieval workflows, not chat I/O. For sending text to an LLM in a conversation, use message types from langchain.messages.

    Base class for all prompt templates, returning a prompt.

    Configuration for a Runnable.

    Note

    Custom values

    The TypedDict has total=False set intentionally to:

    • Allow partial configs to be created and merged together via merge_configs
    • Support config propagation from parent to child runnables via var_child_runnable_config (a ContextVar that automatically passes config down the call stack without explicit parameter passing), where configs are merged rather than replaced
    Example
    # Parent sets tags
    chain.invoke(input, config={"tags": ["parent"]})
    # Child automatically inherits and can add:
    # ensure_config({"tags": ["child"]}) -> {"tags": ["parent", "child"]}