Skip to content

Commit

Permalink
Merge pull request HamaWhiteGG#47 from zhangxiaojiawow/retrievalqa_fo…
Browse files Browse the repository at this point in the history
…rmat_source_documents

return json format of docs in result so that client can parse it easily.
  • Loading branch information
HamaWhiteGG authored Jul 20, 2023
2 parents 1766b71 + e022b0b commit 09a0886
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.collect.Maps;
import com.hw.langchain.chains.base.Chain;
import com.hw.langchain.chains.combine.documents.base.BaseCombineDocumentsChain;
import com.hw.langchain.chains.query.constructor.JsonUtils;
import com.hw.langchain.schema.Document;

import java.util.List;
Expand Down Expand Up @@ -82,7 +83,7 @@ public Map<String, String> innerCall(Map<String, Object> inputs) {
Map<String, String> result = Maps.newHashMap();
result.put(outputKey, answer);
if (this.returnSourceDocuments) {
result.put("source_documents", docs.toString());
result.put("source_documents", JsonUtils.toJsonStringWithIndent(docs, 4));
}
return result;
}
Expand Down

0 comments on commit 09a0886

Please sign in to comment.