diff --git a/locales/en-US/components.json b/locales/en-US/components.json index 0110d9a12db3..e257f5582cd4 100644 --- a/locales/en-US/components.json +++ b/locales/en-US/components.json @@ -59,7 +59,7 @@ "status": { "error": "Chunking failed", "errorResult": "Chunking failed, please check and try again. Error detail:", - "processing": "Chunking in progress.", + "processing": "Chunking", "processingTip": "The server is splitting text chunks; closing the page will not affect the chunking progress." } } diff --git a/src/database/server/models/chunk.ts b/src/database/server/models/chunk.ts index 174f761bc2cf..0a7cd8fce6f2 100644 --- a/src/database/server/models/chunk.ts +++ b/src/database/server/models/chunk.ts @@ -171,6 +171,10 @@ export class ChunkModel { }) { const similarity = sql`1 - (${cosineDistance(embeddings.embeddings, embedding)})`; + const hasFiles = fileIds && fileIds.length > 0; + + if (!hasFiles) return []; + const result = await serverDB .select({ fileId: files.id, @@ -186,7 +190,7 @@ export class ChunkModel { .leftJoin(embeddings, eq(chunks.id, embeddings.chunkId)) .leftJoin(fileChunks, eq(chunks.id, fileChunks.chunkId)) .leftJoin(files, eq(files.id, fileChunks.fileId)) - .where(and(fileIds && fileIds.length > 0 ? inArray(fileChunks.fileId, fileIds) : undefined)) + .where(inArray(fileChunks.fileId, fileIds)) .orderBy((t) => desc(t.similarity)) .limit(5);