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

    string

    BasePrompt schema definition.

    Attributes

    attribute
    formatter
    attribute
    PromptTemplateFormat: Literal['f-string', 'mustache', 'jinja2']
    attribute
    Defs: dict[str, 'Defs']
    attribute
    DEFAULT_FORMATTER_MAPPING: dict[str, Callable[..., str]]
    attribute
    DEFAULT_VALIDATOR_MAPPING: dict[str, Callable]

    Functions

    function
    get_colored_text

    Get colored text.

    function
    is_interactive_env

    Determine if running within IPython or Jupyter.

    function
    jinja2_formatter

    Format a template using jinja2.

    Security

    As of LangChain 0.0.329, this method uses Jinja2's SandboxedEnvironment by default. However, this sandboxing should be treated as a best-effort approach rather than a guarantee of security.

    Do not accept jinja2 templates from untrusted sources as they may lead to arbitrary Python code execution.

    More information.

    function
    validate_jinja2

    Validate that the input variables are valid for the template.

    Issues a warning if missing or extra variables are found.

    function
    mustache_formatter

    Format a template using mustache.

    function
    mustache_template_vars

    Get the top-level variables from a mustache template.

    For nested variables like {{person.name}}, only the top-level key (person) is returned.

    function
    mustache_schema

    Get the variables from a mustache template.

    function
    check_valid_template

    Check that template string is valid.

    function
    get_template_variables

    Get the variables from the template.

    function
    is_subsequence

    Return True if child is subsequence of parent.

    Classes

    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
    BasePromptTemplate

    Base class for all prompt templates, returning a prompt.

    class
    StringPromptTemplate

    String prompt that exposes the format method, returning a prompt.

    Modules

    module
    mustache

    Adapted from https://github.com/noahmorrison/chevron.

    MIT License.

    View source on GitHub