diff --git a/web/app/components/base/input-number/index.tsx b/web/app/components/base/input-number/index.tsx index 222686a0a8..e9792f48ef 100644 --- a/web/app/components/base/input-number/index.tsx +++ b/web/app/components/base/input-number/index.tsx @@ -1,4 +1,3 @@ -import { useState } from 'react' import type { FC, SetStateAction } from 'react' import { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react' import Input, { type InputProps } from '../input' @@ -6,35 +5,34 @@ import classNames from '@/utils/classnames' export type InputNumberProps = { unit?: string + value: number onChange: (value: number) => void amount?: number size?: 'sm' | 'md' } & Omit export const InputNumber: FC = (props) => { - const { unit, className, onChange, defaultValue = 0, amount = 1, size = 'sm', max, min, ...rest } = props - const [val, setVal] = useState(defaultValue as number) - const update = (value: SetStateAction) => { - const current = typeof value === 'function' ? value(val) : value as number + const { unit, className, onChange, amount = 1, value, size = 'sm', max, min, ...rest } = props + const update = (input: SetStateAction) => { + const current = typeof input === 'function' ? input(value) : input as number if (max && current >= (max as number)) return if (min && current <= (min as number)) return - setVal(value) + onChange(current) } const inc = () => update(val => val + amount) const dec = () => update(val => val - amount) return
{ const parsed = Number(e.target.value) if (Number.isNaN(parsed)) return - setVal(parsed) onChange(parsed) }} /> diff --git a/web/app/components/base/param-item/index.tsx b/web/app/components/base/param-item/index.tsx index bd18d35ebc..771893b6a1 100644 --- a/web/app/components/base/param-item/index.tsx +++ b/web/app/components/base/param-item/index.tsx @@ -55,10 +55,8 @@ const ParamItem: FC = ({ className, id, name, noTooltip, tip, step = 0.1, max={max} step={step} size='sm' + value={value} onChange={(value) => { - if (value < min || value > max) - return - onChange(id, value) }} /> diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index dc5258e509..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,24 +662,24 @@ const StepTwo = ({ {t('datasetCreation.stepTwo.previewChunk')} - } >
-
+
setSegmentIdentifier(e.target.value)} /> @@ -749,7 +752,7 @@ const StepTwo = ({ })} /> setParentChildConfig({ ...parentChildConfig, parent: { @@ -775,11 +778,11 @@ const StepTwo = ({ />
-
+
{t('datasetCreation.stepTwo.childChunkForRetrieval')} -
+
setParentChildConfig({ @@ -791,8 +794,7 @@ const StepTwo = ({ })} /> setParentChildConfig({ ...parentChildConfig, child: { @@ -803,20 +805,22 @@ const StepTwo = ({ />
- - {t('datasetCreation.stepTwo.rules')} -
- {rules.map(rule => ( -
{ - ruleChangeHandle(rule.id) - }}> - - -
- ))} + + {t('datasetCreation.stepTwo.rules')} + +
+ {rules.map(rule => ( +
{ + ruleChangeHandle(rule.id) + }}> + + +
+ ))} +
diff --git a/web/app/components/datasets/create/step-two/option-card.tsx b/web/app/components/datasets/create/step-two/option-card.tsx index 5aa398f0f2..da0486d204 100644 --- a/web/app/components/datasets/create/step-two/option-card.tsx +++ b/web/app/components/datasets/create/step-two/option-card.tsx @@ -75,7 +75,7 @@ export const OptionCard: FC = (props) => { /> {/** Body */} {isActive &&
{children} - {actions &&
+ {actions &&
{actions}
}
} diff --git a/web/app/components/datasets/create/stepper/step.tsx b/web/app/components/datasets/create/stepper/step.tsx index f40a275b04..69f524ea66 100644 --- a/web/app/components/datasets/create/stepper/step.tsx +++ b/web/app/components/datasets/create/stepper/step.tsx @@ -27,7 +27,7 @@ export const StepperStep: FC = (props) => {