Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

[FEATURE] QA with Sources

Open beddows opened this issue 2 years ago • 5 comments

Very nice UI!

Would be great if the VectorDB QA Chain node included the parameter returnSourceDocuments (i.e.: setting the returnSourceDocuments to true when calling the chain).

beddows avatar May 17 '23 14:05 beddows

@beddows returnSourceDocuments allows you to get back the different Document chunks like this:

sourceDocuments: [
    Document {
      pageContent: 'somedoc..',
      metadata: [Object]
    },
]

Is that what you are expecting?

HenryHengZJ avatar May 18 '23 17:05 HenryHengZJ

@HenryHengZJ Yes, that looks correct. The metadata can be used by the LLM summarizer to identify the sources of the chunks that are contributing to the final answer (and will provide the sources when prompted to do so).

beddows avatar May 19 '23 00:05 beddows

@beddows do you mind to have a quick test to see if that satisfy your use cases?

In the line under this can you add chain.returnSourceDocuments = true?

My thought is that we'll have to use Output Parser if we want to see the specific source where the answer is from, not sure how to use the sourceDocuments array returned from returnSourceDocuments

HenryHengZJ avatar May 19 '23 10:05 HenryHengZJ

@beddows do you mind to have a quick test to see if that satisfy your use cases?

In the line under this can you add chain.returnSourceDocuments = true?

Hi Henry,

Langchain implementation of ectorDBQAWithSourcesChain is deprecated - It needed to be added in the RetrievalQA Chain

warnings.warn( "VectorDBQAWithSourcesChain is deprecated - " "please use `from langchain.chains import RetrievalQAWithSourcesChain

nmoturi avatar May 19 '23 13:05 nmoturi

Perfect, this line then - https://github.com/FlowiseAI/Flowise/blob/main/packages/components/nodes/chains/RetrievalQAChain/RetrievalQAChain.ts#L43

HenryHengZJ avatar May 19 '23 13:05 HenryHengZJ

Its now supported using ConversationalRetrievalQAChain - https://github.com/FlowiseAI/Flowise/pull/274

HenryHengZJ avatar Jun 10 '23 00:06 HenryHengZJ