Skip to content

RetrievalQA chain return source_documents when using it as a Tool for an Agent #5097

Answered by damiam
damiam asked this question in Q&A
Discussion options

You must be logged in to vote

EDIT:

Tool(
    name="Search summaries",
    func=lambda query: chain({"question": query}),
    description="useful for when you need to answer questions. Input should be a fully formed question."
),

This new func=lambda query: chain({"question": query}) worked for me, but it looks kinda clunky.

the chain is now

chain = RetrievalQA.from_chain_type(llm=llm, chain_type='stuff', retriever=retriever, return_source_documents=True, verbose=True, input_key="question")

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@cnndabbler
Comment options

@Sarthak1306
Comment options

Answer selected by damiam
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants