in RAG project, i am using langchain, when i run the qa chain with query input, this error keep showing up!
here is the error:
—-> result = qa_chain({‘query’: question})
ValueError: Missing some input keys: {‘query’}
here is my code:
from langchain.chains import RetrievalQA
from langchain.prompts import PromptTemplate
# Build prompt
template = """Given the following context answer the question.
Context:
{context}
------------------
Question: {query}
Answer:"""
# LLM chain
QA_CHAIN_PROMPT = PromptTemplate.from_template(template)
qa_chain = RetrievalQA.from_chain_type(
llm,
retriever=vectordb.as_retriever(),
return_source_documents=True,
chain_type_kwargs={"prompt": QA_CHAIN_PROMPT}
)
question = "What methodology was used in this research paper?"
result = qa_chain({'query': question})
# Check the result of the query
result["result"]
# Check the source document from where we
result["source_documents"][0]
New contributor
jana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.