Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãOPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew-shot examples for chat modelsFormat template outputTemplate formatsTypes of MessagePromptTemplatePartial prompt templatesCompositionSerializationPrompt pipeliningValidate templateExample selectorsLanguage modelsOutput parsersRetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesModel I/‚ÄãOPromptsPrompt templatesOn this pagePrompt templatesPrompt templates are pre-defined recipes for generating prompts for language models.A template may include instructions, few-shot examples, and specific context and
questions appropriate for a given task.LangChain provides tooling to create and work with prompt templates.LangChain strives to create model agnostic templates to make it easy to reuse
existing templates across different language models.Typically, language models expect the prompt to either be a string or else a list of chat messages.PromptTemplate‚ÄãUse PromptTemplate to create a template for a string prompt.By default, PromptTemplate uses Python's str.format
syntax for templating.from langchain.prompts import PromptTemplateprompt_template = PromptTemplate.from_template(    "Tell me a {adjective} joke about {content}.")prompt_template.format(adjective="funny", content="chickens")    'Tell me a funny joke about chickens.'The template supports any number of variables, including no variables:nfrom langchain.prompts import PromptTemplateprompt_template = PromptTemplate.from_template("Tell me a joke")prompt_template.format()    'Tell me a joke'For additional validation, specify input_variables explicitly. These variables
Prompt templates are pre-defined recipes for generating prompts for language models.
Prompt templates are pre-defined recipes for generating prompts for language models. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãOPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew-shot examples for chat modelsFormat template outputTemplate formatsTypes of MessagePromptTemplatePartial prompt templatesCompositionSerializationPrompt pipeliningValidate templateExample selectorsLanguage modelsOutput parsersRetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesModel I/‚ÄãOPromptsPrompt templatesOn this pagePrompt templatesPrompt templates are pre-defined recipes for generating prompts for language models.A template may include instructions, few-shot examples, and specific context and
questions appropriate for a given task.LangChain provides tooling to create and work with prompt templates.LangChain strives to create model agnostic templates to make it easy to reuse
existing templates across different language models.Typically, language models expect the prompt to either be a string or else a list of chat messages.PromptTemplate‚ÄãUse PromptTemplate to create a template for a string prompt.By default, PromptTemplate uses Python's str.format
syntax for templating.from langchain.prompts import PromptTemplateprompt_template = PromptTemplate.from_template(    "Tell me a {adjective} joke about {content}.")prompt_template.format(adjective="funny", content="chickens")    'Tell me a funny joke about chickens.'The template supports any number of variables, including no variables:nfrom langchain.prompts import PromptTemplateprompt_template = PromptTemplate.from_template("Tell me a joke")prompt_template.format()    'Tell me a joke'For additional validation, specify input_variables explicitly. These variables