@@ -17,8 +17,8 @@ import type { DocumentSortField, SortOrder } from './types'
1717const logger = createLogger ( 'DocumentService' )
1818
1919const TIMEOUTS = {
20- OVERALL_PROCESSING : env . KB_CONFIG_MAX_DURATION * 1000 ,
21- EMBEDDINGS_API : env . KB_CONFIG_MAX_TIMEOUT * 18 ,
20+ OVERALL_PROCESSING : ( env . KB_CONFIG_MAX_DURATION || 300 ) * 1000 ,
21+ EMBEDDINGS_API : ( env . KB_CONFIG_MAX_TIMEOUT || 10000 ) * 18 ,
2222} as const
2323
2424/**
@@ -38,17 +38,17 @@ function withTimeout<T>(
3838}
3939
4040const PROCESSING_CONFIG = {
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 ,
41+ maxConcurrentDocuments : Math . max ( 1 , Math . floor ( ( env . KB_CONFIG_CONCURRENCY_LIMIT || 20 ) / 5 ) ) || 4 ,
42+ batchSize : Math . max ( 1 , Math . floor ( ( env . KB_CONFIG_BATCH_SIZE || 20 ) / 2 ) ) || 10 ,
43+ delayBetweenBatches : ( env . KB_CONFIG_DELAY_BETWEEN_BATCHES || 100 ) * 2 ,
44+ delayBetweenDocuments : ( env . KB_CONFIG_DELAY_BETWEEN_DOCUMENTS || 50 ) * 2 ,
4545}
4646
4747const REDIS_PROCESSING_CONFIG = {
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 ,
48+ maxConcurrentDocuments : env . KB_CONFIG_CONCURRENCY_LIMIT || 20 ,
49+ batchSize : env . KB_CONFIG_BATCH_SIZE || 20 ,
50+ delayBetweenBatches : env . KB_CONFIG_DELAY_BETWEEN_BATCHES || 100 ,
51+ delayBetweenDocuments : env . KB_CONFIG_DELAY_BETWEEN_DOCUMENTS || 50 ,
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 : env . KB_CONFIG_MIN_TIMEOUT ,
63- maxRetries : env . KB_CONFIG_MAX_ATTEMPTS ,
62+ retryDelay : env . KB_CONFIG_MIN_TIMEOUT || 1000 ,
63+ maxRetries : env . KB_CONFIG_MAX_ATTEMPTS || 3 ,
6464 } )
6565 }
6666 return documentQueue
0 commit comments