Return_source_documents when RetrievalQA is an Agent tool #5909
Unanswered
pythonhacknewby
asked this question in
Q&A
Replies: 1 comment
-
Found the answer here. Sorry, originally missed it... |
Beta Was this translation helpful? Give feedback.
0 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 can return source documents fine when I run this code without being a tool in an agent. But when I run this code as part of an agent, below I get an error if I "return_source_documents" as a tool in an agent. I know it is from the qa.run since it returns more than one, but cant figure out how to fix it. I have commented out several tries of mine. Any help would be very much appreciated!
Doesn't work:
def qa_chat3(vector_store, query):
vectorstore = u.load_vectorstore(vector_store)
template="You are an expert test taker."
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template="Answer this question: {queries}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])
qa = RetrievalQAWithSourcesChain.from_chain_type(
Declared outside of function
memory = ConversationBufferMemory(
memory_key="chat_history")
This works fine:
Question and answer llm
def qa_llm(vector_store, queries):
vectorstore = u.load_vectorstore(vector_store)
Beta Was this translation helpful? Give feedback.
All reactions