Skip to content

Commit 003b32d

Browse files
committed
remove dead code
1 parent 488ef20 commit 003b32d

7 files changed

Lines changed: 18 additions & 83 deletions

File tree

apps/sim/app/api/knowledge/[id]/documents/route.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,8 @@ describe('Knowledge Base Documents API Route', () => {
457457
},
458458
],
459459
processingOptions: {
460-
chunkSize: 1024,
461-
minCharactersPerChunk: 100,
462460
recipe: 'default',
463461
lang: 'en',
464-
chunkOverlap: 200,
465462
},
466463
}
467464

@@ -533,11 +530,8 @@ describe('Knowledge Base Documents API Route', () => {
533530
},
534531
],
535532
processingOptions: {
536-
chunkSize: 50, // Invalid: too small
537-
minCharactersPerChunk: 0, // Invalid: too small
538533
recipe: 'default',
539534
lang: 'en',
540-
chunkOverlap: 1000, // Invalid: too large
541535
},
542536
}
543537

apps/sim/app/api/knowledge/[id]/documents/route.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,14 @@ const CreateDocumentSchema = z.object({
3838
documentTagsData: z.string().optional(),
3939
})
4040

41-
/**
42-
* Schema for bulk document creation with processing options.
43-
* Chunking fields are optional — the server falls back to the KB's stored chunkingConfig.
44-
*
45-
* Processing options units:
46-
* - chunkSize: tokens (1 token ≈ 4 characters)
47-
* - minCharactersPerChunk: characters
48-
* - chunkOverlap: tokens (1 token ≈ 4 characters)
49-
*/
5041
const BulkCreateDocumentsSchema = z.object({
5142
documents: z.array(CreateDocumentSchema),
52-
processingOptions: z.object({
53-
/** Maximum chunk size in tokens (1 token ≈ 4 characters) */
54-
chunkSize: z.number().min(100).max(4000).optional(),
55-
/** Minimum chunk size in characters */
56-
minCharactersPerChunk: z.number().min(1).max(2000).optional(),
57-
recipe: z.string().optional(),
58-
lang: z.string().optional(),
59-
/** Overlap between chunks in tokens (1 token ≈ 4 characters) */
60-
chunkOverlap: z.number().min(0).max(500).optional(),
61-
}),
43+
processingOptions: z
44+
.object({
45+
recipe: z.string().optional(),
46+
lang: z.string().optional(),
47+
})
48+
.optional(),
6249
bulk: z.literal(true),
6350
})
6451

@@ -247,8 +234,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
247234
knowledgeBaseId,
248235
documentsCount: createdDocuments.length,
249236
uploadType: 'bulk',
250-
chunkSize: validatedData.processingOptions.chunkSize,
251-
recipe: validatedData.processingOptions.recipe,
237+
recipe: validatedData.processingOptions?.recipe,
252238
})
253239
} catch (_e) {
254240
// Silently fail
@@ -257,7 +243,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
257243
processDocumentsWithQueue(
258244
createdDocuments,
259245
knowledgeBaseId,
260-
validatedData.processingOptions,
246+
validatedData.processingOptions ?? {},
261247
requestId
262248
).catch((error: unknown) => {
263249
logger.error(`[${requestId}] Critical error in document processing pipeline:`, error)

apps/sim/app/api/knowledge/[id]/documents/upsert/route.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ const UpsertDocumentSchema = z.object({
2525
fileSize: z.number().min(1, 'File size must be greater than 0'),
2626
mimeType: z.string().min(1, 'MIME type is required'),
2727
documentTagsData: z.string().optional(),
28-
processingOptions: z.object({
29-
chunkSize: z.number().min(100).max(4000).optional(),
30-
minCharactersPerChunk: z.number().min(1).max(2000).optional(),
31-
recipe: z.string().optional(),
32-
lang: z.string().optional(),
33-
chunkOverlap: z.number().min(0).max(500).optional(),
34-
}),
28+
processingOptions: z
29+
.object({
30+
recipe: z.string().optional(),
31+
lang: z.string().optional(),
32+
})
33+
.optional(),
3534
workflowId: z.string().optional(),
3635
})
3736

@@ -166,7 +165,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
166165
processDocumentsWithQueue(
167166
createdDocuments,
168167
knowledgeBaseId,
169-
validatedData.processingOptions,
168+
validatedData.processingOptions ?? {},
170169
requestId
171170
).catch((error: unknown) => {
172171
logger.error(`[${requestId}] Critical error in document processing pipeline:`, error)
@@ -178,8 +177,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
178177
knowledgeBaseId,
179178
documentsCount: 1,
180179
uploadType: 'single',
181-
chunkSize: validatedData.processingOptions.chunkSize,
182-
recipe: validatedData.processingOptions.recipe,
180+
recipe: validatedData.processingOptions?.recipe,
183181
})
184182
} catch (_e) {
185183
// Silently fail

apps/sim/app/workspace/[workspaceId]/knowledge/components/create-base-modal/create-base-modal.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,6 @@ export const CreateBaseModal = memo(function CreateBaseModal({
269269
if (files.length > 0) {
270270
try {
271271
const uploadedFiles = await uploadFiles(files, newKnowledgeBase.id, {
272-
chunkSize: data.maxChunkSize,
273-
minCharactersPerChunk: data.minChunkSize,
274-
chunkOverlap: data.overlapSize,
275272
recipe: 'default',
276273
})
277274

apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ export interface UploadError {
4646
}
4747

4848
export interface ProcessingOptions {
49-
chunkSize?: number
50-
minCharactersPerChunk?: number
51-
chunkOverlap?: number
5249
recipe?: string
5350
}
5451

@@ -1011,13 +1008,6 @@ export function useKnowledgeUpload(options: UseKnowledgeUploadOptions = {}) {
10111008
...file,
10121009
})),
10131010
processingOptions: {
1014-
...(processingOptions.chunkSize != null && { chunkSize: processingOptions.chunkSize }),
1015-
...(processingOptions.minCharactersPerChunk != null && {
1016-
minCharactersPerChunk: processingOptions.minCharactersPerChunk,
1017-
}),
1018-
...(processingOptions.chunkOverlap != null && {
1019-
chunkOverlap: processingOptions.chunkOverlap,
1020-
}),
10211011
recipe: processingOptions.recipe ?? 'default',
10221012
lang: 'en',
10231013
},

apps/sim/background/knowledge-processing.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ export type DocumentProcessingPayload = {
1515
mimeType: string
1616
}
1717
processingOptions: {
18-
chunkSize?: number
19-
minCharactersPerChunk?: number
2018
recipe?: string
2119
lang?: string
22-
chunkOverlap?: number
2320
}
2421
requestId: string
2522
}

apps/sim/lib/knowledge/documents/service.ts

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,8 @@ export interface DocumentData {
101101
}
102102

103103
export interface ProcessingOptions {
104-
chunkSize?: number
105-
minCharactersPerChunk?: number
106104
recipe?: string
107105
lang?: string
108-
chunkOverlap?: number
109106
}
110107

111108
export interface DocumentJobData {
@@ -416,13 +413,7 @@ export async function processDocumentAsync(
416413
fileSize: number
417414
mimeType: string
418415
},
419-
processingOptions: {
420-
chunkSize?: number
421-
minCharactersPerChunk?: number
422-
recipe?: string
423-
lang?: string
424-
chunkOverlap?: number
425-
}
416+
processingOptions: ProcessingOptions = {}
426417
): Promise<void> {
427418
const startTime = Date.now()
428419
try {
@@ -1573,16 +1564,6 @@ export async function retryDocumentProcessing(
15731564
},
15741565
requestId: string
15751566
): Promise<{ success: boolean; status: string; message: string }> {
1576-
const kb = await db
1577-
.select({
1578-
chunkingConfig: knowledgeBase.chunkingConfig,
1579-
})
1580-
.from(knowledgeBase)
1581-
.where(eq(knowledgeBase.id, knowledgeBaseId))
1582-
.limit(1)
1583-
1584-
const kbConfig = kb[0].chunkingConfig as { maxSize: number; minSize: number; overlap: number }
1585-
15861567
await db.transaction(async (tx) => {
15871568
await tx.delete(embedding).where(eq(embedding.documentId, documentId))
15881569

@@ -1600,14 +1581,6 @@ export async function retryDocumentProcessing(
16001581
.where(eq(document.id, documentId))
16011582
})
16021583

1603-
const processingOptions = {
1604-
chunkSize: kbConfig.maxSize,
1605-
minCharactersPerChunk: kbConfig.minSize,
1606-
recipe: 'default',
1607-
lang: 'en',
1608-
chunkOverlap: kbConfig.overlap,
1609-
}
1610-
16111584
await processDocumentsWithQueue(
16121585
[
16131586
{
@@ -1619,7 +1592,7 @@ export async function retryDocumentProcessing(
16191592
},
16201593
],
16211594
knowledgeBaseId,
1622-
processingOptions,
1595+
{},
16231596
requestId
16241597
)
16251598

0 commit comments

Comments
 (0)