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-corepromptschatBaseStringMessagePromptTemplatefrom_template
    Method●Since v0.1

    from_template

    Create a class from a string template.

    Copy
    from_template(
      cls,
      template: str,
      template_format: PromptTemplateFormat = 'f-string',
      partial_variables: dict[str, Any] | None = None,
      **kwargs: Any = {}
    ) -> Self

    Parameters

    NameTypeDescription
    template*str

    a template.

    template_formatPromptTemplateFormat
    Default:'f-string'

    format of the template.

    partial_variablesdict[str, Any] | None
    Default:None

    A dictionary of variables that can be used to partially fill in the template.

    For example, if the template is "{variable1} {variable2}", and partial_variables is {"variable1": "foo"}, then the final prompt will be "foo {variable2}".

    **kwargsAny
    Default:{}

    Keyword arguments to pass to the constructor.

    View source on GitHub