I'm trying to create a routing chain in langchain with different rags based on the route, each having a different prompt template, and this is the code I have:
period_template = """AAAText
Domanda:
{input}"""
ref_template = """BBBtext.
Domanda:
{input}"""
list_template = """CCCText.
Domanda:
{input}"""
prompt_infos = [
{
"name": "period",
"description": "AAA",
"prompt_template": period_template
},
{
"name": "ref",
"description": "BBB",
"prompt_template": ref_template
},
{
"name": "history",
"description": "CCC",
"prompt_template": list_template
}
]
destination_chains = {}
for p_info in prompt_infos:
PROMPT = PromptTemplate(template=p_info["prompt_template"], input_variables=["input"])
chain = RetrievalQA.from_chain_type(
chat_model,
retriever=db.as_retriever(),
return_source_documents=True,
chain_type_kwargs={"prompt": PROMPT}
)
destination_chains[p_info["name"]] = chain
I get the error:
ValidationError: 1 validation error for StuffDocumentsChain root document_variable_name context was not found in llm_chain input_variables: ['input'] (type=value_error)
What's wrong and how can I resolve it?