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

    Functions

    Classes

    Modules

    View source on GitHub
    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]
    function
    get_colored_text
    function
    is_interactive_env
    function
    jinja2_formatter
    function
    validate_jinja2
    function
    mustache_formatter
    function
    mustache_template_vars
    function
    mustache_schema
    function
    validate_f_string_template
    function
    check_valid_template
    function
    get_template_variables
    function
    is_subsequence
    class
    PromptValue
    class
    StringPromptValue
    class
    BasePromptTemplate
    class
    StringPromptTemplate
    module
    mustache

    Get colored text.

    Determine if running within IPython or Jupyter.

    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.

    Validate that the input variables are valid for the template.

    Issues a warning if missing or extra variables are found.

    Format a template using mustache.

    Get the top-level variables from a mustache template.

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

    Get the variables from a mustache template.

    Validate an f-string template and return its input variables.

    Check that template string is valid.

    Get the variables from the template.

    Return True if child is subsequence of parent.

    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.

    Base class for all prompt templates, returning a prompt.

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

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

    MIT License.