From db1956ed54425390109ea081685c1ac03fbc907d Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Tue, 26 Nov 2024 15:37:57 +0800 Subject: [PATCH] feat: dataset creation form reset --- .../datasets/create/step-two/index.tsx | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index f42261b348..0f929888c8 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -119,6 +119,19 @@ type ParentChildConfig = { rules: PreProcessingRule[] } +const defaultParentChildConfig: ParentChildConfig = { + chunkForContext: 'paragraph', + parent: { + delimiter: '\\n\\n', + maxLength: 4000, + }, + child: { + delimiter: '\\n\\n', + maxLength: 4000, + }, + rules: [], +} + const StepTwo = ({ isSetting, documentDetail, @@ -186,18 +199,7 @@ const StepTwo = ({ })() const [isCreating, setIsCreating] = useState(false) - const [parentChildConfig, setParentChildConfig] = useState({ - chunkForContext: 'paragraph', - parent: { - delimiter: '\\n\\n', - maxLength: 4000, - }, - child: { - delimiter: '\\n\\n', - maxLength: 4000, - }, - rules: [], - }) + const [parentChildConfig, setParentChildConfig] = useState(defaultParentChildConfig) const scrollHandle = (e: Event) => { if ((e.target as HTMLDivElement).scrollTop > 0) @@ -248,6 +250,7 @@ const StepTwo = ({ setOverlap(defaultConfig.segmentation.chunk_overlap) setRules(defaultConfig.pre_processing_rules) } + setParentChildConfig(defaultParentChildConfig) } const fetchFileIndexingEstimate = async (docForm = DocForm.TEXT, language?: string) => { @@ -659,7 +662,7 @@ const StepTwo = ({ {t('datasetCreation.stepTwo.previewChunk')} -