0

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:

ValueError: Missing some input keys: {'query'}

Here's how I've set up my CustomMultiPromptChain class:

class CustomMultiPromptChain (MultiRouteChain):
        destination_chains: Mapping[str, Chain]
        """Map of name to candidate chains that inputs can be routed to. Not restricted to LLM"""

Here's how I am initializing and using it:

    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})

I expected it to run the prompt on the correct chain and provide the output but instead I am getting this error mentioned above. 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.

How can I resolve the error?

desertnaut
  • 57,590
  • 26
  • 140
  • 166

0 Answers0