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

    from_examples

    Take examples in list format with prefix and suffix to create a prompt.

    Intended to be used as a way to dynamically create a prompt from examples.

    Copy
    from_examples(
      cls,
      examples: list[str],
      suffix: str,
      input_variables: list[str],
      example_separator: str = '\n\n',
      prefix: str = '',
      **kwargs: Any = {}
    ) -> PromptTemplate

    Parameters

    NameTypeDescription
    examples*list[str]

    List of examples to use in the prompt.

    suffix*str

    String to go after the list of examples.

    Should generally set up the user's input.

    input_variables*list[str]

    A list of variable names the final prompt template will expect.

    example_separatorstr
    Default:'\n\n'

    The separator to use in between examples.

    prefixstr
    Default:''

    String that should go before any examples.

    Generally includes examples.

    View source on GitHub