@@ -44,23 +44,33 @@ const FormSchema = z
4444 . max ( 100 , 'Name must be less than 100 characters' )
4545 . refine ( ( value ) => value . trim ( ) . length > 0 , 'Name cannot be empty' ) ,
4646 description : z . string ( ) . max ( 500 , 'Description must be less than 500 characters' ) . optional ( ) ,
47+ /** Minimum chunk size in characters */
4748 minChunkSize : z
4849 . number ( )
49- . min ( 1 , 'Min chunk size must be at least 1' )
50- . max ( 2000 , 'Min chunk size must be less than 2000' ) ,
50+ . min ( 1 , 'Min chunk size must be at least 1 character' )
51+ . max ( 2000 , 'Min chunk size must be less than 2000 characters' ) ,
52+ /** Maximum chunk size in tokens (1 token ≈ 4 characters) */
5153 maxChunkSize : z
5254 . number ( )
53- . min ( 100 , 'Max chunk size must be at least 100' )
54- . max ( 4000 , 'Max chunk size must be less than 4000' ) ,
55+ . min ( 100 , 'Max chunk size must be at least 100 tokens' )
56+ . max ( 4000 , 'Max chunk size must be less than 4000 tokens' ) ,
57+ /** Overlap between chunks in tokens */
5558 overlapSize : z
5659 . number ( )
57- . min ( 0 , 'Overlap size must be non-negative' )
58- . max ( 500 , 'Overlap size must be less than 500' ) ,
59- } )
60- . refine ( ( data ) => data . minChunkSize < data . maxChunkSize , {
61- message : 'Min chunk size must be less than max chunk size' ,
62- path : [ 'minChunkSize' ] ,
60+ . min ( 0 , 'Overlap must be non-negative' )
61+ . max ( 500 , 'Overlap must be less than 500 tokens' ) ,
6362 } )
63+ . refine (
64+ ( data ) => {
65+ // Convert maxChunkSize from tokens to characters for comparison (1 token ≈ 4 chars)
66+ const maxChunkSizeInChars = data . maxChunkSize * 4
67+ return data . minChunkSize < maxChunkSizeInChars
68+ } ,
69+ {
70+ message : 'Min chunk size (characters) must be less than max chunk size (tokens × 4)' ,
71+ path : [ 'minChunkSize' ] ,
72+ }
73+ )
6474
6575type FormValues = z . infer < typeof FormSchema >
6676
@@ -123,7 +133,7 @@ export function CreateBaseModal({
123133 defaultValues : {
124134 name : '' ,
125135 description : '' ,
126- minChunkSize : 1 ,
136+ minChunkSize : 100 ,
127137 maxChunkSize : 1024 ,
128138 overlapSize : 200 ,
129139 } ,
@@ -143,7 +153,7 @@ export function CreateBaseModal({
143153 reset ( {
144154 name : '' ,
145155 description : '' ,
146- minChunkSize : 1 ,
156+ minChunkSize : 100 ,
147157 maxChunkSize : 1024 ,
148158 overlapSize : 200 ,
149159 } )
@@ -381,10 +391,10 @@ export function CreateBaseModal({
381391 < div className = 'space-y-[12px] rounded-[6px] bg-[var(--surface-6)] px-[12px] py-[14px]' >
382392 < div className = 'grid grid-cols-2 gap-[12px]' >
383393 < div className = 'flex flex-col gap-[8px]' >
384- < Label htmlFor = 'minChunkSize' > Min Chunk Size</ Label >
394+ < Label htmlFor = 'minChunkSize' > Min Chunk Size (characters) </ Label >
385395 < Input
386396 id = 'minChunkSize'
387- placeholder = '1 '
397+ placeholder = '100 '
388398 { ...register ( 'minChunkSize' , { valueAsNumber : true } ) }
389399 className = { cn ( errors . minChunkSize && 'border-[var(--text-error)]' ) }
390400 autoComplete = 'off'
@@ -394,7 +404,7 @@ export function CreateBaseModal({
394404 </ div >
395405
396406 < div className = 'flex flex-col gap-[8px]' >
397- < Label htmlFor = 'maxChunkSize' > Max Chunk Size</ Label >
407+ < Label htmlFor = 'maxChunkSize' > Max Chunk Size (tokens) </ Label >
398408 < Input
399409 id = 'maxChunkSize'
400410 placeholder = '1024'
@@ -408,7 +418,7 @@ export function CreateBaseModal({
408418 </ div >
409419
410420 < div className = 'flex flex-col gap-[8px]' >
411- < Label htmlFor = 'overlapSize' > Overlap Size </ Label >
421+ < Label htmlFor = 'overlapSize' > Overlap (tokens) </ Label >
412422 < Input
413423 id = 'overlapSize'
414424 placeholder = '200'
@@ -419,6 +429,9 @@ export function CreateBaseModal({
419429 name = 'overlap-size'
420430 />
421431 </ div >
432+ < p className = 'text-[11px] text-[var(--text-muted)]' >
433+ 1 token ≈ 4 characters. Max chunk size and overlap are in tokens.
434+ </ p >
422435 </ div >
423436
424437 < div className = 'flex flex-col gap-[8px]' >
0 commit comments