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 templatesPrompt pipeliningOn this pagePrompt pipeliningThe idea behind prompt pipelining is to provide a user friendly interface for composing different parts of prompts together. You can do this with either string prompts or chat prompts. Constructing prompts this way allows for easy reuse of components.String prompt pipelining‚ÄãWhen working with string prompts, each template is joined together. You can work with either prompts directly or strings (the first element in the list needs to be a prompt).from langchain.prompts import PromptTemplateprompt = (    PromptTemplate.from_template("Tell me a joke about {topic}")    + ", make it funny"    + "\n\nand in {language}")prompt    PromptTemplate(input_variables=['language', 'topic'], output_parser=None, partial_variables={}, template='Tell me a joke about {topic}, make it funny\n\nand in {language}', template_format='f-string', validate_template=True)prompt.format(topic="sports", language="spanish")    'Tell me a joke about sports, make it funny\n\nand in spanish'You can also use it in an LLMChain, just like before.from langchain.chat_models import ChatOpenAIfrom langchain.chains import LLMChainmodel = ChatOpenAI()chain = LLMChain(llm=model, prompt=prompt)chain.run(topic="sports", language="spanish")    '¬øPor qu√© el
The idea behind prompt pipelining is to provide a user friendly interface for composing different parts of prompts together. You can do this with either string prompts or chat prompts. Constructing prompts this way allows for easy reuse of components.
The idea behind prompt pipelining is to provide a user friendly interface for composing different parts of prompts together. You can do this with either string prompts or chat prompts. Constructing prompts this way allows for easy reuse of components. ->: 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 templatesPrompt pipeliningOn this pagePrompt pipeliningThe idea behind prompt pipelining is to provide a user friendly interface for composing different parts of prompts together. You can do this with either string prompts or chat prompts. Constructing prompts this way allows for easy reuse of components.String prompt pipelining‚ÄãWhen working with string prompts, each template is joined together. You can work with either prompts directly or strings (the first element in the list needs to be a prompt).from langchain.prompts import PromptTemplateprompt = (    PromptTemplate.from_template("Tell me a joke about {topic}")    + ", make it funny"    + "\n\nand in {language}")prompt    PromptTemplate(input_variables=['language', 'topic'], output_parser=None, partial_variables={}, template='Tell me a joke about {topic}, make it funny\n\nand in {language}', template_format='f-string', validate_template=True)prompt.format(topic="sports", language="spanish")    'Tell me a joke about sports, make it funny\n\nand in spanish'You can also use it in an LLMChain, just like before.from langchain.chat_models import ChatOpenAIfrom langchain.chains import LLMChainmodel = ChatOpenAI()chain = LLMChain(llm=model, prompt=prompt)chain.run(topic="sports", language="spanish")    '¬øPor qu√© el