diff --git a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx index 175b31154e..84d742d734 100644 --- a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx +++ b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx @@ -53,6 +53,7 @@ type GeneralChunkingOptionsProps = { onReset: () => void // Locale locale: string + showSummaryIndexSetting?: boolean summaryIndexSetting?: SummaryIndexSettingType onSummaryIndexSettingChange?: (payload: SummaryIndexSettingType) => void } @@ -77,6 +78,7 @@ export const GeneralChunkingOptions: FC = ({ onPreview, onReset, locale, + showSummaryIndexSetting, summaryIndexSetting, onSummaryIndexSettingChange, }) => { @@ -151,13 +153,17 @@ export const GeneralChunkingOptions: FC = ({ ))} -
- -
+ { + showSummaryIndexSetting && ( +
+ +
+ ) + } {IS_CE_EDITION && ( <> diff --git a/web/app/components/datasets/create/step-two/components/parent-child-options.tsx b/web/app/components/datasets/create/step-two/components/parent-child-options.tsx index 9a3fabfd71..22b88037e1 100644 --- a/web/app/components/datasets/create/step-two/components/parent-child-options.tsx +++ b/web/app/components/datasets/create/step-two/components/parent-child-options.tsx @@ -49,6 +49,7 @@ type ParentChildOptionsProps = { onRuleToggle: (id: string) => void onPreview: () => void onReset: () => void + showSummaryIndexSetting?: boolean } export const ParentChildOptions: FC = ({ @@ -69,6 +70,7 @@ export const ParentChildOptions: FC = ({ onSummaryIndexSettingChange, onPreview, onReset, + showSummaryIndexSetting, }) => { const { t } = useTranslation() @@ -188,13 +190,17 @@ export const ParentChildOptions: FC = ({ ))} -
- -
+ { + showSummaryIndexSetting && ( +
+ +
+ ) + } diff --git a/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts b/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts index 27dca8f48f..41c34a9a96 100644 --- a/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts +++ b/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts @@ -43,7 +43,7 @@ export type UseSegmentationStateOptions = { } export const useSegmentationState = (options: UseSegmentationStateOptions = {}) => { - const { initialSegmentationType } = options + const { initialSegmentationType, initialSummaryIndexSetting } = options // Segmentation type (general or parent-child) const [segmentationType, setSegmentationType] = useState( @@ -59,8 +59,8 @@ export const useSegmentationState = (options: UseSegmentationStateOptions = {}) // Pre-processing rules const [rules, setRules] = useState([]) const [defaultConfig, setDefaultConfig] = useState() - const [summaryIndexSetting, setSummaryIndexSetting] = useState() - const summaryIndexSettingRef = useRef(summaryIndexSetting) + const [summaryIndexSetting, setSummaryIndexSetting] = useState(initialSummaryIndexSetting) + const summaryIndexSettingRef = useRef(initialSummaryIndexSetting) const handleSummaryIndexSettingChange = useCallback((payload: SummaryIndexSettingType) => { setSummaryIndexSetting({ ...summaryIndexSettingRef.current, ...payload }) summaryIndexSettingRef.current = { ...summaryIndexSettingRef.current, ...payload } diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index f9f0ea03d7..a77d829488 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -67,6 +67,7 @@ const StepTwo: FC = ({ initialSegmentationType: currentDataset?.doc_form === ChunkingMode.parentChild ? ProcessMode.parentChild : ProcessMode.general, initialSummaryIndexSetting: currentDataset?.summary_index_setting, }) + const showSummaryIndexSetting = !currentDataset const indexing = useIndexingConfig({ initialIndexType: propsIndexingType, initialEmbeddingModel: currentDataset?.embedding_model ? { provider: currentDataset.embedding_model_provider, model: currentDataset.embedding_model } : undefined, @@ -218,6 +219,7 @@ const StepTwo: FC = ({ onPreview={updatePreview} onReset={segmentation.resetToDefaults} locale={locale} + showSummaryIndexSetting={showSummaryIndexSetting} summaryIndexSetting={segmentation.summaryIndexSetting} onSummaryIndexSettingChange={segmentation.handleSummaryIndexSettingChange} /> @@ -239,6 +241,7 @@ const StepTwo: FC = ({ onRuleToggle={segmentation.toggleRule} onPreview={updatePreview} onReset={segmentation.resetToDefaults} + showSummaryIndexSetting={showSummaryIndexSetting} summaryIndexSetting={segmentation.summaryIndexSetting} onSummaryIndexSettingChange={segmentation.handleSummaryIndexSettingChange} />