You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue with MultiRetrievalQAChain when using returnSourceDocuments option #2355
Hi, Im trying to implement MultiRetrievalQAChain which works as expected without the option returnSourceDocuments but as I need source documents to further generate referral links or to analyse what has been retrieved, Im unable to do so because it seems passing this option is breaking some lc function that does not have info of passed parameter returnSourceDocuments
return MultiRetrievalQAChain.fromLLMAndRetrievers(chatGPT3Model, {
retrieverNames,
retrieverDescriptions,
retrievers,
retrievalQAChainOpts: {
// Enabling below breaks the chain and unable to produce output
returnSourceDocuments: true,
},
});
Based on the information you've provided and the context from the LangChain repository, it seems that the MultiRetrievalQAChain class does support the returnSourceDocuments option. However, there might be some confusion about how to access the returned source documents.
In LangChain, the source documents are returned in the sourceDocuments property, not the source property. Here's how you can modify your function to return the source documents:
This will print the pageContent of the first source document. If you want to print all source documents, you can loop over the source array.
If you're still encountering issues, could you please provide the exact error message or describe the behavior you're observing when the returnSourceDocuments option is set to true? This will help me better understand the problem and provide a more accurate solution.
Activity
dosubot commentedon Aug 21, 2023
🤖
Hi there,
Based on the information you've provided and the context from the LangChain repository, it seems that the
MultiRetrievalQAChainclass does support thereturnSourceDocumentsoption. However, there might be some confusion about how to access the returned source documents.In LangChain, the source documents are returned in the
sourceDocumentsproperty, not thesourceproperty. Here's how you can modify your function to return the source documents:In your function, you should also adjust the console log to handle the
sourceas an array, assourceDocumentsis an array of source documents:This will print the
pageContentof the first source document. If you want to print all source documents, you can loop over thesourcearray.If you're still encountering issues, could you please provide the exact error message or describe the behavior you're observing when the
returnSourceDocumentsoption is set totrue? This will help me better understand the problem and provide a more accurate solution.Best,
Dosu
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with Dosu Bot (@dosu-bot).
ashbuilds commentedon Aug 21, 2023
Actually, I got my answer below, thanks to bot! https://github.com/hwchase17/langchainjs/blob/main/langchain/src/chains/router/tests/multi_retrieval_qa.test.ts#L132