fix totalChars accumulator for undefined pageContent (#2619)

This commit is contained in:
Jared McQueen 2024-06-11 17:05:04 -04:00 committed by GitHub
parent 6fb775fe95
commit 5e4d640ed7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -600,7 +600,12 @@ const _saveChunksToStorage = async (data: IDocumentStoreLoaderForPreview, entity
await appServer.AppDataSource.getRepository(DocumentStoreFileChunk).delete({ docId: newLoaderId })
if (response.chunks) {
//step 8: now save the new chunks
const totalChars = response.chunks.reduce((acc: number, chunk) => acc + chunk.pageContent.length, 0)
const totalChars = response.chunks.reduce((acc, chunk) => {
if (chunk.pageContent) {
return acc + chunk.pageContent.length
}
return acc
}, 0)
response.chunks.map(async (chunk: IDocument, index: number) => {
const docChunk: DocumentStoreFileChunk = {
docId: newLoaderId,