@@ -17,8 +17,8 @@ import type { DocumentSortField, SortOrder } from './types'
1717const logger = createLogger ( 'DocumentService' )
1818
1919const TIMEOUTS = {
20- OVERALL_PROCESSING : 600000 ,
21- EMBEDDINGS_API : 180000 ,
20+ OVERALL_PROCESSING : env . KB_CONFIG_MAX_DURATION * 1000 ,
21+ EMBEDDINGS_API : env . KB_CONFIG_MAX_TIMEOUT * 18 ,
2222} as const
2323
2424/**
@@ -38,17 +38,17 @@ function withTimeout<T>(
3838}
3939
4040const PROCESSING_CONFIG = {
41- maxConcurrentDocuments : 4 ,
42- batchSize : 10 ,
43- delayBetweenBatches : 200 ,
44- delayBetweenDocuments : 100 ,
41+ maxConcurrentDocuments : Math . max ( 1 , Math . floor ( env . KB_CONFIG_CONCURRENCY_LIMIT / 5 ) ) || 4 ,
42+ batchSize : Math . max ( 1 , Math . floor ( env . KB_CONFIG_BATCH_SIZE / 2 ) ) || 10 ,
43+ delayBetweenBatches : env . KB_CONFIG_DELAY_BETWEEN_BATCHES * 2 ,
44+ delayBetweenDocuments : env . KB_CONFIG_DELAY_BETWEEN_DOCUMENTS * 2 ,
4545}
4646
4747const REDIS_PROCESSING_CONFIG = {
48- maxConcurrentDocuments : 12 ,
49- batchSize : 20 ,
50- delayBetweenBatches : 100 ,
51- delayBetweenDocuments : 50 ,
48+ maxConcurrentDocuments : env . KB_CONFIG_CONCURRENCY_LIMIT ,
49+ batchSize : env . KB_CONFIG_BATCH_SIZE ,
50+ delayBetweenBatches : env . KB_CONFIG_DELAY_BETWEEN_BATCHES ,
51+ delayBetweenDocuments : env . KB_CONFIG_DELAY_BETWEEN_DOCUMENTS ,
5252}
5353
5454let documentQueue : DocumentProcessingQueue | null = null
@@ -59,8 +59,8 @@ export function getDocumentQueue(): DocumentProcessingQueue {
5959 const config = redisClient ? REDIS_PROCESSING_CONFIG : PROCESSING_CONFIG
6060 documentQueue = new DocumentProcessingQueue ( {
6161 maxConcurrent : config . maxConcurrentDocuments ,
62- retryDelay : 2000 ,
63- maxRetries : 5 ,
62+ retryDelay : env . KB_CONFIG_MIN_TIMEOUT ,
63+ maxRetries : env . KB_CONFIG_MAX_ATTEMPTS ,
6464 } )
6565 }
6666 return documentQueue
0 commit comments