fix: delimiter not support empty and not escape

This commit is contained in:
Joel 2024-12-18 14:25:56 +08:00
parent 0006852b5b
commit ade6dd4b6f
1 changed files with 5 additions and 5 deletions

View File

@ -157,8 +157,8 @@ const StepTwo = ({
const dataSourceType = isInCreatePage ? inCreatePageDataSourceType : currentDataset?.data_source_type
const [segmentationType, setSegmentationType] = useState<SegmentType>(SegmentType.CUSTOM)
const [segmentIdentifier, doSetSegmentIdentifier] = useState(DEFAULT_SEGMENT_IDENTIFIER)
const setSegmentIdentifier = useCallback((value: string) => {
doSetSegmentIdentifier(value ? escape(value) : DEFAULT_SEGMENT_IDENTIFIER)
const setSegmentIdentifier = useCallback((value: string, canEmpty?: boolean) => {
doSetSegmentIdentifier(value ? escape(value) : (canEmpty ? '' : DEFAULT_SEGMENT_IDENTIFIER))
}, [])
const [maxChunkLength, setMaxChunkLength] = useState(DEFAULT_MAXMIMUM_CHUNK_LENGTH) // default chunk length
const [limitMaxChunkLength, setLimitMaxChunkLength] = useState(4000)
@ -612,7 +612,7 @@ const StepTwo = ({
<div className='flex gap-3'>
<DelimiterInput
value={segmentIdentifier}
onChange={e => setSegmentIdentifier(e.target.value)}
onChange={e => setSegmentIdentifier(e.target.value, true)}
/>
<MaxLengthInput
value={maxChunkLength}
@ -737,7 +737,7 @@ const StepTwo = ({
...parentChildConfig,
parent: {
...parentChildConfig.parent,
delimiter: e.target.value,
delimiter: e.target.value ? escape(e.target.value) : '',
},
})}
/>
@ -782,7 +782,7 @@ const StepTwo = ({
...parentChildConfig,
child: {
...parentChildConfig.child,
delimiter: e.target.value,
delimiter: e.target.value ? escape(e.target.value) : '',
},
})}
/>