From 28091c21018677355a124dd9c46213db3a229183 Mon Sep 17 00:00:00 2001 From: jrhe <4038905+jrhe@users.noreply.github.com> Date: Wed, 10 May 2023 00:15:25 +0100 Subject: [PATCH] Use passed LLM for default chain in MultiPromptChain (#4418) Currently, MultiPromptChain instantiates a ChatOpenAI LLM instance for the default chain to use if none of the prompts passed match. This seems like an error as it means that you can't use your choice of LLM, or configure how to instantiate the default LLM (e.g. passing in an API key that isn't in the usual env variable). --- langchain/chains/router/multi_prompt.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/langchain/chains/router/multi_prompt.py b/langchain/chains/router/multi_prompt.py index cd0c8ef0..df108a1e 100644 --- a/langchain/chains/router/multi_prompt.py +++ b/langchain/chains/router/multi_prompt.py @@ -9,7 +9,6 @@ from langchain.chains.llm import LLMChain from langchain.chains.router.base import MultiRouteChain from langchain.chains.router.llm_router import LLMRouterChain, RouterOutputParser from langchain.chains.router.multi_prompt_prompt import MULTI_PROMPT_ROUTER_TEMPLATE -from langchain.chat_models import ChatOpenAI from langchain.prompts import PromptTemplate @@ -54,9 +53,7 @@ class MultiPromptChain(MultiRouteChain): prompt = PromptTemplate(template=prompt_template, input_variables=["input"]) chain = LLMChain(llm=llm, prompt=prompt) destination_chains[name] = chain - _default_chain = default_chain or ConversationChain( - llm=ChatOpenAI(), output_key="text" - ) + _default_chain = default_chain or ConversationChain(llm=llm, output_key="text") return cls( router_chain=router_chain, destination_chains=destination_chains,