Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsFoundationalSequentialOn this pageSequentialThe next step after calling a language model is to make a series of calls to a language model. This is particularly useful when you want to take the output from one call and use it as the input to another.In this notebook we will walk through some examples of how to do this, using sequential chains. Sequential chains allow you to connect multiple chains and compose them into pipelines that execute some specific scenario. There are two types of sequential chains:SimpleSequentialChain: The simplest form of sequential chains, where each step has a singular input/output, and the output of one step is the input to the next.SequentialChain: A more general form of sequential chains, allowing for multiple inputs/outputs.from langchain.llms import OpenAIfrom langchain.chains import LLMChainfrom langchain.prompts import PromptTemplate# This is an LLMChain to write a synopsis given a title of a play.llm = OpenAI(temperature=.7)synopsis_template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title.Title: {title}Playwright: This is a synopsis for the above play:"""synopsis_prompt_template = PromptTemplate(input_variables=["title"], template=synopsis_template)synopsis_chain = LLMChain(llm=llm, prompt=synopsis_prompt_template)# This is an LLMChain to write a review of a play given a synopsis.llm = OpenAI(temperature=.7)template = """You are a play critic from the New York Times. Given the synopsis of play, it is your job to write a review for that play.Play
The next step after calling a language model is to make a series of calls to a language model. This is particularly useful when you want to take the output from one call and use it as the input to another.
The next step after calling a language model is to make a series of calls to a language model. This is particularly useful when you want to take the output from one call and use it as the input to another. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsFoundationalSequentialOn this pageSequentialThe next step after calling a language model is to make a series of calls to a language model. This is particularly useful when you want to take the output from one call and use it as the input to another.In this notebook we will walk through some examples of how to do this, using sequential chains. Sequential chains allow you to connect multiple chains and compose them into pipelines that execute some specific scenario. There are two types of sequential chains:SimpleSequentialChain: The simplest form of sequential chains, where each step has a singular input/output, and the output of one step is the input to the next.SequentialChain: A more general form of sequential chains, allowing for multiple inputs/outputs.from langchain.llms import OpenAIfrom langchain.chains import LLMChainfrom langchain.prompts import PromptTemplate# This is an LLMChain to write a synopsis given a title of a play.llm = OpenAI(temperature=.7)synopsis_template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title.Title: {title}Playwright: This is a synopsis for the above play:"""synopsis_prompt_template = PromptTemplate(input_variables=["title"], template=synopsis_template)synopsis_chain = LLMChain(llm=llm, prompt=synopsis_prompt_template)# This is an LLMChain to write a review of a play given a synopsis.llm = OpenAI(temperature=.7)template = """You are a play critic from the New York Times. Given the synopsis of play, it is your job to write a review for that play.Play