How to route to other type Chains, such as QA Chain, instead of LLMChain in destination_train #6285
flashslothless
started this conversation in
General
Replies: 1 comment 3 replies
-
Cause:MultiRouteChain is base abastract class, does not include implemtation. Solution:If you need to route to different type of destination chain instead of LLM, you need to extend MultiRouteChain to your class.
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to router request to 2 Chains by using RouterChains:
It works when all destiation_trains is LLMChain, but when I set one to be QA Chains, it always got errors below:
ValidationError Traceback (most recent call last)
Cell In[21], line 12
6 router_prompt = PromptTemplate(
7 template=router_template,
8 input_variables=["input"],
9 output_parser=RouterOutputParser(),
10 )
11 router_chain = LLMRouterChain.from_llm(llm, router_prompt)
---> 12 chain = MultiPromptChain(router_chain=router_chain, destination_chains=destination_chains, default_chain=default_chain, verbose=True)
File ~/anaconda3/envs/python3/lib/python3.10/site-packages/langchain/load/serializable.py:61, in Serializable.init(self, **kwargs)
60 def init(self, **kwargs: Any) -> None:
---> 61 super().init(**kwargs)
62 self.lc_kwargs = kwargs
File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pydantic/main.py:341, in pydantic.main.BaseModel.init()
ValidationError: 6 validation errors for MultiPromptChain
destination_chains -> QA1 -> prompt
field required (type=value_error.missing)
destination_chains -> QA1 -> llm
field required (type=value_error.missing)
destination_chains -> QA1 -> combine_documents_chain
extra fields not permitted (type=value_error.extra)
destination_chains -> QA1 -> input_key
extra fields not permitted (type=value_error.extra)
destination_chains -> QA1 -> retriever
extra fields not permitted (type=value_error.extra)
destination_chains -> QA1 -> return_source_documents
extra fields not permitted (type=value_error.extra)
QA1 Chain can work well when I test it seperately, and all parameters are set.
Any advises are apprecited!
Beta Was this translation helpful? Give feedback.
All reactions