Merge pull request #1127 from chz8494/memory_replace_fix

[Bug] Fix Cannot read properties of undefined (reading 'replace')
pull/1158/head
Henry Heng 2023-10-29 10:33:33 +00:00 committed by GitHub
commit 06552416bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -71,7 +71,9 @@ class InMemoryVectorStore_VectorStores implements INode {
const flattenDocs = docs && docs.length ? flatten(docs) : []
const finalDocs = []
for (let i = 0; i < flattenDocs.length; i += 1) {
finalDocs.push(new Document(flattenDocs[i]))
if (flattenDocs[i] !== undefined && flattenDocs[i].pageContent !== undefined) {
finalDocs.push(new Document(flattenDocs[i]))
}
}
const vectorStore = await MemoryVectorStore.fromDocuments(finalDocs, embeddings)