Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsFoundationalRouterOn this pageRouterThis notebook demonstrates how to use the RouterChain paradigm to create a chain that dynamically selects the next chain to use for a given input. Router chains are made up of two components:The RouterChain itself (responsible for selecting the next chain to call)destination_chains: chains that the router chain can route toIn this notebook, we will focus on the different types of routing chains. We will show these routing chains used in a MultiPromptChain to create a question-answering chain that selects the prompt which is most relevant for a given question, and then answers the question using that prompt.from langchain.chains.router import MultiPromptChainfrom langchain.llms import OpenAIfrom langchain.chains import ConversationChainfrom langchain.chains.llm import LLMChainfrom langchain.prompts import PromptTemplatephysics_template = """You are a very smart physics professor. \You are great at answering questions about physics in a concise and easy to understand manner. \When you don't know the answer to a question you admit that you don't know.Here is a question:{input}"""math_template = """You are a very good mathematician. You are great at answering math questions. \You are so good because you are able to break down hard problems into their component parts, \answer the component parts, and then put them together to answer the broader question.Here is a question:{input}"""prompt_infos = [    {        "name": "physics",        "description": "Good for answering questions about physics",        "prompt_template":
This notebook demonstrates how to use the RouterChain paradigm to create a chain that dynamically selects the next chain to use for a given input.
This notebook demonstrates how to use the RouterChain paradigm to create a chain that dynamically selects the next chain to use for a given input. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsFoundationalRouterOn this pageRouterThis notebook demonstrates how to use the RouterChain paradigm to create a chain that dynamically selects the next chain to use for a given input. Router chains are made up of two components:The RouterChain itself (responsible for selecting the next chain to call)destination_chains: chains that the router chain can route toIn this notebook, we will focus on the different types of routing chains. We will show these routing chains used in a MultiPromptChain to create a question-answering chain that selects the prompt which is most relevant for a given question, and then answers the question using that prompt.from langchain.chains.router import MultiPromptChainfrom langchain.llms import OpenAIfrom langchain.chains import ConversationChainfrom langchain.chains.llm import LLMChainfrom langchain.prompts import PromptTemplatephysics_template = """You are a very smart physics professor. \You are great at answering questions about physics in a concise and easy to understand manner. \When you don't know the answer to a question you admit that you don't know.Here is a question:{input}"""math_template = """You are a very good mathematician. You are great at answering math questions. \You are so good because you are able to break down hard problems into their component parts, \answer the component parts, and then put them together to answer the broader question.Here is a question:{input}"""prompt_infos = [    {        "name": "physics",        "description": "Good for answering questions about physics",        "prompt_template":