Hello fellow developers,
I'm currently working on a project where I'm using the MultiPromptChain from langchain to route inputs to different chains based on specific conditions. However, I'm facing an issue with inputs that's been quite puzzling. I'm hoping someone can provide some guidance to help me resolve this.
Problem Description:
I have a scenario where I'm using multiple RetrievalQA chains, each with different formatting instructions and prompt templates. To handle this, I'm utilizing the MultiPromptChain from langchain to determine which chain to route the inputs to. However, when I attempt to execute the chains, I'm encountering the following error:
Error:
ValueError: Missing some input keys: {'query'}
My Implementation:
Here's how I've set up my CustomMultiPromptChain class and how I'm initializing and using it:
`class CustomMultiPromptChain (MultiRouteChain):
destination_chains: Mapping[str, Chain]
"""Map of name to candidate chains that inputs can be routed to. Not restricted to LLM"""
destination_chains = {}
for p_info in prompt_infos:
name = p_info["name"]
chain_kwargs = p_info["kwargs"]
chain = RetrievalQA.from_chain_type(llm=ChatOpenAI(model="gpt-4"), chain_type="stuff", retriever=retriever, chain_type_kwargs=chain_kwargs)
destination_chains[name] = chain
chain = CustomMultiPromptChain(
router_chain=router_chain,
destination_chains=destination_chains,
default_chain=default_chain,
verbose=True,
)
chain({"input": input})`
Steps Taken:
I've verified the expected input keys for each chain in destination_chains.
I've tried changing the input variable from 'input' to 'query' in my call to the chain instance.
Any help, suggestions, or insights would be highly appreciated. Thank you for taking the time to read through this and assist me in resolving this issue!