Skip to content

Commit

Permalink
Change chat splitter function
Browse files Browse the repository at this point in the history
  • Loading branch information
thivy committed Aug 8, 2023
1 parent 5fbce7e commit 127c6e5
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/features/chat/chat-services/chat-document-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ const LoadFile = async (formData: FormData) => {
};

const SplitDocuments = async (docs: Array<Document>) => {
const splitDocuments: Array<Document> = [];
for (const doc of docs) {
const splitter = new RecursiveCharacterTextSplitter();
const output = await splitter.createDocuments([doc.pageContent]);
splitDocuments.push(...output);
}
return splitDocuments;
const allContent = docs.map((doc) => doc.pageContent).join("\n");
const splitter = new RecursiveCharacterTextSplitter();
const output = await splitter.createDocuments([allContent]);
return output;
};

const IndexDocuments = async (
Expand Down

0 comments on commit 127c6e5

Please sign in to comment.