@@ -30,7 +30,7 @@ import {
3030import { recordUsage } from '@/lib/billing/core/usage-log'
3131import { checkAndBillOverageThreshold } from '@/lib/billing/threshold-billing'
3232import type { ChunkingStrategy , StrategyOptions } from '@/lib/chunkers/types'
33- import { env } from '@/lib/core/config/env'
33+ import { env , envNumber } from '@/lib/core/config/env'
3434import { getCostMultiplier , isTriggerDevEnabled } from '@/lib/core/config/feature-flags'
3535import { processDocument } from '@/lib/knowledge/documents/document-processor'
3636import type { DocumentSortField , SortOrder } from '@/lib/knowledge/documents/types'
@@ -54,12 +54,12 @@ import { calculateCost } from '@/providers/utils'
5454const logger = createLogger ( 'DocumentService' )
5555
5656const TIMEOUTS = {
57- OVERALL_PROCESSING : ( env . KB_CONFIG_MAX_DURATION || 600 ) * 1000 ,
57+ OVERALL_PROCESSING : envNumber ( env . KB_CONFIG_MAX_DURATION , 600 ) * 1000 ,
5858} as const
5959
6060const LARGE_DOC_CONFIG = {
6161 MAX_CHUNKS_PER_BATCH : 500 ,
62- MAX_EMBEDDING_BATCH : env . KB_CONFIG_BATCH_SIZE || 2000 ,
62+ MAX_EMBEDDING_BATCH : envNumber ( env . KB_CONFIG_BATCH_SIZE , 2000 ) ,
6363 MAX_FILE_SIZE : 100 * 1024 * 1024 ,
6464 MAX_CHUNKS_PER_DOCUMENT : 100000 ,
6565}
@@ -78,10 +78,11 @@ function withTimeout<T>(
7878}
7979
8080const PROCESSING_CONFIG = {
81- maxConcurrentDocuments : Math . max ( 1 , Math . floor ( ( env . KB_CONFIG_CONCURRENCY_LIMIT || 20 ) / 5 ) ) || 4 ,
82- batchSize : Math . max ( 1 , Math . floor ( ( env . KB_CONFIG_BATCH_SIZE || 20 ) / 2 ) ) || 10 ,
83- delayBetweenBatches : ( env . KB_CONFIG_DELAY_BETWEEN_BATCHES || 100 ) * 2 ,
84- delayBetweenDocuments : ( env . KB_CONFIG_DELAY_BETWEEN_DOCUMENTS || 50 ) * 2 ,
81+ maxConcurrentDocuments :
82+ Math . max ( 1 , Math . floor ( envNumber ( env . KB_CONFIG_CONCURRENCY_LIMIT , 20 ) / 5 ) ) || 4 ,
83+ batchSize : Math . max ( 1 , Math . floor ( envNumber ( env . KB_CONFIG_BATCH_SIZE , 20 ) / 2 ) ) || 10 ,
84+ delayBetweenBatches : envNumber ( env . KB_CONFIG_DELAY_BETWEEN_BATCHES , 100 ) * 2 ,
85+ delayBetweenDocuments : envNumber ( env . KB_CONFIG_DELAY_BETWEEN_DOCUMENTS , 50 ) * 2 ,
8586}
8687
8788export function getProcessingConfig ( ) {
0 commit comments