feat: dataset creation form reset

feat/parent-child-retrieval-api
AkaraChen 2 years ago
parent 1843f6ccb6
commit db1956ed54

@ -119,6 +119,19 @@ type ParentChildConfig = {
rules: PreProcessingRule[] rules: PreProcessingRule[]
} }
const defaultParentChildConfig: ParentChildConfig = {
chunkForContext: 'paragraph',
parent: {
delimiter: '\\n\\n',
maxLength: 4000,
},
child: {
delimiter: '\\n\\n',
maxLength: 4000,
},
rules: [],
}
const StepTwo = ({ const StepTwo = ({
isSetting, isSetting,
documentDetail, documentDetail,
@ -186,18 +199,7 @@ const StepTwo = ({
})() })()
const [isCreating, setIsCreating] = useState(false) const [isCreating, setIsCreating] = useState(false)
const [parentChildConfig, setParentChildConfig] = useState<ParentChildConfig>({ const [parentChildConfig, setParentChildConfig] = useState<ParentChildConfig>(defaultParentChildConfig)
chunkForContext: 'paragraph',
parent: {
delimiter: '\\n\\n',
maxLength: 4000,
},
child: {
delimiter: '\\n\\n',
maxLength: 4000,
},
rules: [],
})
const scrollHandle = (e: Event) => { const scrollHandle = (e: Event) => {
if ((e.target as HTMLDivElement).scrollTop > 0) if ((e.target as HTMLDivElement).scrollTop > 0)
@ -248,6 +250,7 @@ const StepTwo = ({
setOverlap(defaultConfig.segmentation.chunk_overlap) setOverlap(defaultConfig.segmentation.chunk_overlap)
setRules(defaultConfig.pre_processing_rules) setRules(defaultConfig.pre_processing_rules)
} }
setParentChildConfig(defaultParentChildConfig)
} }
const fetchFileIndexingEstimate = async (docForm = DocForm.TEXT, language?: string) => { const fetchFileIndexingEstimate = async (docForm = DocForm.TEXT, language?: string) => {
@ -659,7 +662,7 @@ const StepTwo = ({
<RiSearchEyeLine className='h-4 w-4 mr-1.5' /> <RiSearchEyeLine className='h-4 w-4 mr-1.5' />
{t('datasetCreation.stepTwo.previewChunk')} {t('datasetCreation.stepTwo.previewChunk')}
</Button> </Button>
<Button variant={'ghost'} disabled> <Button variant={'ghost'} onClick={resetRules}>
{t('datasetCreation.stepTwo.reset')} {t('datasetCreation.stepTwo.reset')}
</Button> </Button>
</> </>

Loading…
Cancel
Save