about physics",        "prompt_template": physics_template,    },    {        "name": "math",        "description": "Good for answering math questions",        "prompt_template": math_template,    },]llm = OpenAI()destination_chains = {}for p_info in prompt_infos:    name = p_info["name"]    prompt_template = p_info["prompt_template"]    prompt = PromptTemplate(template=prompt_template, input_variables=["input"])    chain = LLMChain(llm=llm, prompt=prompt)    destination_chains[name] = chaindefault_chain = ConversationChain(llm=llm, output_key="text")LLMRouterChain‚ÄãThis chain uses an LLM to determine how to route things.from langchain.chains.router.llm_router import LLMRouterChain, RouterOutputParserfrom langchain.chains.router.multi_prompt_prompt import MULTI_PROMPT_ROUTER_TEMPLATEdestinations = [f"{p['name']}: {p['description']}" for p in prompt_infos]destinations_str = "\n".join(destinations)router_template = MULTI_PROMPT_ROUTER_TEMPLATE.format(destinations=destinations_str)router_prompt = PromptTemplate(    template=router_template,    input_variables=["input"],    output_parser=RouterOutputParser(),)router_chain = LLMRouterChain.from_llm(llm, router_prompt)chain = MultiPromptChain(    router_chain=router_chain,    destination_chains=destination_chains,    default_chain=default_chain,    verbose=True,)print(chain.run("What is black body radiation?"))            > Entering new MultiPromptChain chain...    physics: {'input': 'What is black body radiation?'}    > Finished chain.            Black body radiation is the term used to describe the electromagnetic radiation emitted by a ‚Äúblack body‚Äù‚Äîan object that absorbs all radiation incident upon it. A black body is an idealized physical body that absorbs all incident electromagnetic radiation, regardless of frequency or angle of incidence. It does not reflect, emit or transmit energy. This type of radiation is the result of the thermal motion of the body's atoms and molecules, and it is emitted at all
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. ->: about physics",        "prompt_template": physics_template,    },    {        "name": "math",        "description": "Good for answering math questions",        "prompt_template": math_template,    },]llm = OpenAI()destination_chains = {}for p_info in prompt_infos:    name = p_info["name"]    prompt_template = p_info["prompt_template"]    prompt = PromptTemplate(template=prompt_template, input_variables=["input"])    chain = LLMChain(llm=llm, prompt=prompt)    destination_chains[name] = chaindefault_chain = ConversationChain(llm=llm, output_key="text")LLMRouterChain‚ÄãThis chain uses an LLM to determine how to route things.from langchain.chains.router.llm_router import LLMRouterChain, RouterOutputParserfrom langchain.chains.router.multi_prompt_prompt import MULTI_PROMPT_ROUTER_TEMPLATEdestinations = [f"{p['name']}: {p['description']}" for p in prompt_infos]destinations_str = "\n".join(destinations)router_template = MULTI_PROMPT_ROUTER_TEMPLATE.format(destinations=destinations_str)router_prompt = PromptTemplate(    template=router_template,    input_variables=["input"],    output_parser=RouterOutputParser(),)router_chain = LLMRouterChain.from_llm(llm, router_prompt)chain = MultiPromptChain(    router_chain=router_chain,    destination_chains=destination_chains,    default_chain=default_chain,    verbose=True,)print(chain.run("What is black body radiation?"))            > Entering new MultiPromptChain chain...    physics: {'input': 'What is black body radiation?'}    > Finished chain.            Black body radiation is the term used to describe the electromagnetic radiation emitted by a ‚Äúblack body‚Äù‚Äîan object that absorbs all radiation incident upon it. A black body is an idealized physical body that absorbs all incident electromagnetic radiation, regardless of frequency or angle of incidence. It does not reflect, emit or transmit energy. This type of radiation is the result of the thermal motion of the body's atoms and molecules, and it is emitted at all