Harrison/source docs (#1275)

Co-authored-by: Tushar Dhadiwal <tushardhadiwal@users.noreply.github.com>
This commit is contained in:
Harrison Chase 2023-02-24 07:09:10 -08:00 committed by GitHub
parent 9becdeaadf
commit 4b5d427421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,7 +101,7 @@ class ChatVectorDBChain(Chain, BaseModel):
else:
return {self.output_key: answer}
async def _acall(self, inputs: Dict[str, Any]) -> Dict[str, str]:
async def _acall(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
question = inputs["question"]
chat_history_str = _get_chat_history(inputs["chat_history"])
vectordbkwargs = inputs.get("vectordbkwargs", {})
@ -119,4 +119,7 @@ class ChatVectorDBChain(Chain, BaseModel):
new_inputs["question"] = new_question
new_inputs["chat_history"] = chat_history_str
answer, _ = await self.combine_docs_chain.acombine_docs(docs, **new_inputs)
return {self.output_key: answer}
if self.return_source_documents:
return {self.output_key: answer, "source_documents": docs}
else:
return {self.output_key: answer}