From 791a75f7a3feb07ca316f7102c3d71870d0572cb Mon Sep 17 00:00:00 2001 From: John Wang Date: Sun, 16 Jun 2024 10:25:34 -0700 Subject: [PATCH] Handle binary blobs (#1493) --- core/indexing/LanceDbIndex.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index de871e053..a7012ca9e 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -79,15 +79,26 @@ export class LanceDbIndex implements CodebaseIndex { const content = contents[i]; const chunks: Chunk[] = []; + let hasEmptyChunks = false; + for await (const chunk of chunkDocument( items[i].path, content, LanceDbIndex.MAX_CHUNK_SIZE, items[i].cacheKey, )) { + if (chunk.content.length == 0) { + hasEmptyChunks = true; + break; + } chunks.push(chunk); } + if (hasEmptyChunks) { + // File did not chunk properly, let's skip it. + continue; + } + if (chunks.length > 20) { // Too many chunks to index, probably a larger file than we want to include continue;