diff --git a/admin/app/jobs/embed_file_job.ts b/admin/app/jobs/embed_file_job.ts index 0c59b32..0c0a12f 100644 --- a/admin/app/jobs/embed_file_job.ts +++ b/admin/app/jobs/embed_file_job.ts @@ -1,4 +1,4 @@ -import { Job } from 'bullmq' +import { Job, UnrecoverableError } from 'bullmq' import { QueueService } from '#services/queue_service' import { EmbedJobWithProgress } from '../../types/rag.js' import { RagService } from '#services/rag_service' @@ -42,7 +42,15 @@ export class EmbedFileJob { const ragService = new RagService(dockerService, ollamaService) try { - // Check if Ollama and Qdrant services are ready + // Check if Ollama and Qdrant services are installed and ready + // Use UnrecoverableError for "not installed" so BullMQ won't retry — + // retrying 30x when the service doesn't exist just wastes Redis connections + const ollamaUrl = await dockerService.getServiceURL('nomad_ollama') + if (!ollamaUrl) { + logger.warn('[EmbedFileJob] Ollama is not installed. Skipping embedding for: %s', fileName) + throw new UnrecoverableError('Ollama service is not installed. Install AI Assistant to enable file embeddings.') + } + const existingModels = await ollamaService.getModels() if (!existingModels) { logger.warn('[EmbedFileJob] Ollama service not ready yet. Will retry...') @@ -51,8 +59,8 @@ export class EmbedFileJob { const qdrantUrl = await dockerService.getServiceURL('nomad_qdrant') if (!qdrantUrl) { - logger.warn('[EmbedFileJob] Qdrant service not ready yet. Will retry...') - throw new Error('Qdrant service not ready yet') + logger.warn('[EmbedFileJob] Qdrant is not installed. Skipping embedding for: %s', fileName) + throw new UnrecoverableError('Qdrant service is not installed. Install AI Assistant to enable file embeddings.') } logger.info(`[EmbedFileJob] Services ready. Processing file: ${fileName}`) diff --git a/admin/app/jobs/run_download_job.ts b/admin/app/jobs/run_download_job.ts index 3cc09ad..c7f672e 100644 --- a/admin/app/jobs/run_download_job.ts +++ b/admin/app/jobs/run_download_job.ts @@ -82,14 +82,17 @@ export class RunDownloadJob { const zimService = new ZimService(dockerService) await zimService.downloadRemoteSuccessCallback([url], true) - // Dispatch an embedding job for the downloaded ZIM file - try { - await EmbedFileJob.dispatch({ - fileName: url.split('/').pop() || '', - filePath: filepath, - }) - } catch (error) { - console.error(`[RunDownloadJob] Error dispatching EmbedFileJob for URL ${url}:`, error) + // Only dispatch embedding job if AI Assistant (Ollama) is installed + const ollamaUrl = await dockerService.getServiceURL('nomad_ollama') + if (ollamaUrl) { + try { + await EmbedFileJob.dispatch({ + fileName: url.split('/').pop() || '', + filePath: filepath, + }) + } catch (error) { + console.error(`[RunDownloadJob] Error dispatching EmbedFileJob for URL ${url}:`, error) + } } } else if (filetype === 'map') { const mapsService = new MapService()