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

    attribute
    FormatOutputType

    Functions

    function
    create_message

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

    function
    dumpd

    Return a dict representation of an object.

    function
    ensure_config

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

    function
    create_model_v2

    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.

    function
    format_document

    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.

    function
    aformat_document

    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.

    Classes

    class
    ErrorCode

    Error codes.

    class
    BaseOutputParser

    Base class to parse the output of an LLM call.

    Output parsers help structure language model responses.

    class
    ChatPromptValueConcrete

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

    For use in external schemas.

    class
    PromptValue

    Base abstract class for inputs to any language model.

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

    class
    StringPromptValue

    String prompt value.

    class
    RunnableConfig

    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"]}
    class
    RunnableSerializable

    Runnable that can be serialized to JSON.

    class
    Document

    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.

    class
    BasePromptTemplate

    Base class for all prompt templates, returning a prompt.

    View source on GitHub