Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: render Manual Chunker config in dataset parser tabs (#20043)

chanx6a9d388a3974
diff --git a/web/src/components/pipeline-operator-tabs/parser-config-validation.ts b/web/src/components/pipeline-operator-tabs/parser-config-validation.ts
index 6e7a8044b7..7e1b9a3cb2 100644
--- a/web/src/components/pipeline-operator-tabs/parser-config-validation.ts
+++ b/web/src/components/pipeline-operator-tabs/parser-config-validation.ts
@@ -46,6 +46,7 @@ function getOperatorFormSchema(operatorType: Operator, t: TFunction) {
case Operator.GeneralChunker:
return TokenChunkerFormSchema;
case Operator.TitleChunker:
+ case Operator.ManualChunker:
return TitleChunkerFormSchema;
case Operator.Extractor:
return ExtractorFormSchema;
@@ -67,6 +68,7 @@ function getOperatorInitialValues(operatorType: Operator) {
case Operator.GeneralChunker:
return initialGeneralChunkerValues;
case Operator.TitleChunker:
+ case Operator.ManualChunker:
return initialTitleChunkerValues;
case Operator.Extractor:
return initialGoExtractorValues;
diff --git a/web/src/components/pipeline-operator-tabs/pipeline-operator-form.tsx b/web/src/components/pipeline-operator-tabs/pipeline-operator-form.tsx
index 423da244a9..79edc11dd6 100644
--- a/web/src/components/pipeline-operator-tabs/pipeline-operator-form.tsx
+++ b/web/src/components/pipeline-operator-tabs/pipeline-operator-form.tsx
@@ -100,6 +100,18 @@ const PipelineOperatorForm = ({
externalErrors={externalErrors}
/>
);
+ case Operator.ManualChunker:
+ // The backend pins ManualChunker to the title chunker's "group" method
+ // (manual.go) and ignores its token cap, so expose only the rules.
+ return (
+ <TitleChunkerForm
+ node={node}
+ onValuesChange={handleValuesChange}
+ hideOutputs
+ externalErrors={externalErrors}
+ pinMethodGroup
+ />
+ );
case Operator.Extractor:
return (
<ExtractorForm
diff --git a/web/src/constants/agent.tsx b/web/src/constants/agent.tsx
index f4c10afe80..20bb8bfb73 100644
--- a/web/src/constants/agent.tsx
+++ b/web/src/constants/agent.tsx
@@ -133,6 +133,7 @@ export enum Operator {
GeneralChunker = 'GeneralChunker',
TokenChunker = 'TokenChunker',
TitleChunker = 'TitleChunker',
+ ManualChunker = 'ManualChunker',
TableChunker = 'TableChunker',
QAChunker = 'QAChunker',
OneChunker = 'OneChunker',
diff --git a/web/src/pages/agent/form/title-chunker-form/index.tsx b/web/src/pages/agent/form/title-chunker-form/index.tsx
index a37d1b6516..a7c8dcd583 100644
--- a/web/src/pages/agent/form/title-chunker-form/index.tsx
+++ b/web/src/pages/agent/form/title-chunker-form/index.tsx
@@ -10,6 +10,7 @@ import { Input } from '@/components/ui/input';
import { Switch } from '@/components/ui/switch';
import { cn } from '@/lib/utils';
import { zodResolver } from '@hookform/resolvers/zod';
+import { omit } from 'lodash';
import { ChevronDown, ChevronUp, Trash2 } from 'lucide-react';
import { memo, useCallback, useState } from 'react';
import {
@@ -224,17 +225,44 @@ function RulesFieldArray({ name }: RulesFieldArrayProps) {
);
}
+function RootChunkAsHeadingItem() {
+ const { t } = useTranslation();
+ return (
+ <RAGFlowFormItem
+ name="root_chunk_as_heading"
+ label={t('flow.rootAsHeading', 'Use root as heading')}
+ tooltip={t(
+ 'flow.rootAsHeadingTip',
+ 'Treat the root node as a H0 heading when building the hierarchy',
+ )}
+ horizontal={true}
+ labelClassName="w-full"
+ valueClassName="w-8"
+ >
+ {(field) => (
+ <Switch checked={field.value} onCheckedChange={field.onChange} />
+ )}
+ </RAGFlowFormItem>
+ );
+}
+
const TitleChunkerForm = ({
node,
onValuesChange,
hideOutputs,
externalErrors,
-}: INextOperatorForm) => {
+ pinMethodGroup,
+}: INextOperatorForm & { pinMethodGroup?: boolean }) => {
const { t } = useTranslation();
const initialValues = useFormValues(initialTitleChunkerValues, node);
const form = useForm<TitleChunkerFormSchemaType>({
- defaultValues: transformApiResponseToForm(initialValues),
+ defaultValues: pinMethodGroup
+ ? {
+ ...transformApiResponseToForm(initialValues),
+ method: TitleChunkerMethod.Group,
+ }
+ : transformApiResponseToForm(initialValues),
resolver: zodResolver(FormSchema),
mode: 'onChange',
});
@@ -251,8 +279,21 @@ const TitleChunkerForm = ({
const hierarchyOptions = useDynamicHierarchyOptions(form, activeRulesName);
+ const handleValuesChange = useCallback(
+ (values: any) => {
+ if (!pinMethodGroup) {
+ onValuesChange?.(values);
+ return;
+ }
+ onValuesChange?.(
+ omit(values, ['include_heading_content', 'chunk_token_cap']),
+ );
+ },
+ [pinMethodGroup, onValuesChange],
+ );
+
useWatchFormChange(node?.id, form);
- useFormChangeCallback(form, onValuesChange);
+ useFormChangeCallback(form, handleValuesChange);
const handleToggleShowAllTip = useCallback(() => {
setShowAllTip((prev) => !prev);
@@ -261,24 +302,26 @@ const TitleChunkerForm = ({
return (
<Form {...form}>
<FormWrapper>
- <RenderField
- field={{
- name: 'method',
- type: FormFieldType.Segmented,
- label: '',
- options: [
- {
- label: t('flow.hierarchy'),
- value: TitleChunkerMethod.Hierarchy,
- },
- // { label: t('flow.tree', 'Tree'), value: 'tree' },
- {
- label: t('flow.group', 'Group'),
- value: TitleChunkerMethod.Group,
- },
- ],
- }}
- />
+ {!pinMethodGroup && (
+ <RenderField
+ field={{
+ name: 'method',
+ type: FormFieldType.Segmented,
+ label: '',
+ options: [
+ {
+ label: t('flow.hierarchy'),
+ value: TitleChunkerMethod.Hierarchy,
+ },
+ // { label: t('flow.tree', 'Tree'), value: 'tree' },
+ {
+ label: t('flow.group', 'Group'),
+ value: TitleChunkerMethod.Group,
+ },
+ ],
+ }}
+ />
+ )}
<div
className={`text-xs text-text-secondary w-full cursor-pointer `}
onClick={handleToggleShowAllTip}
@@ -301,16 +344,18 @@ const TitleChunkerForm = ({
</div>
</div>
</div>
- <SliderInputFormField
- name="chunk_token_cap"
- max={8000}
- min={128}
- label={t('flow.chunkTokenCap', 'Chunk token cap')}
- tooltip={t(
- 'flow.chunkTokenCapTip',
- 'Maximum tokens per chunk. Chunks exceeding the cap are re-split on sentence boundaries (Chinese/English period, exclamation mark, question mark, newline). 0 disables the cap.',
- )}
- />
+ {!pinMethodGroup && (
+ <SliderInputFormField
+ name="chunk_token_cap"
+ max={8000}
+ min={128}
+ label={t('flow.chunkTokenCap', 'Chunk token cap')}
+ tooltip={t(
+ 'flow.chunkTokenCapTip',
+ 'Maximum tokens per chunk. Chunks exceeding the cap are re-split on sentence boundaries (Chinese/English period, exclamation mark, question mark, newline). 0 disables the cap.',
+ )}
+ />
+ )}
<RAGFlowFormItem
name={'hierarchyHierarchy'}
label={''}
@@ -345,26 +390,10 @@ const TitleChunkerForm = ({
)}
</RAGFlowFormItem>
- <RAGFlowFormItem
- name="root_chunk_as_heading"
- label={t('flow.rootAsHeading', 'Use root as heading')}
- tooltip={t(
- 'flow.rootAsHeadingTip',
- 'Treat the root node as a H0 heading when building the hierarchy',
- )}
- horizontal={true}
- labelClassName="w-full"
- valueClassName="w-8"
- >
- {(field) => (
- <Switch
- checked={field.value}
- onCheckedChange={field.onChange}
- />
- )}
- </RAGFlowFormItem>
+ <RootChunkAsHeadingItem />
</>
)}
+ {pinMethodGroup && <RootChunkAsHeadingItem />}
<div
className={
method === TitleChunkerMethod.Hierarchy ? 'block' : 'hidden'
diff --git a/web/src/utils/pipeline-operator.ts b/web/src/utils/pipeline-operator.ts
index 2295be26b3..a956481b2f 100644
--- a/web/src/utils/pipeline-operator.ts
+++ b/web/src/utils/pipeline-operator.ts
@@ -35,7 +35,7 @@ import {
transformTokenChunkerParams,
} from '@/pages/agent/utils';
import { pickByBackend } from '@/utils/backend-variant';
-import { cloneDeep, isEmpty } from 'lodash';
+import { cloneDeep, isEmpty, omit } from 'lodash';
export const FileNodeId = 'File';
@@ -339,6 +339,7 @@ export function transformApiConfigToForm(
case Operator.GeneralChunker:
return transformGeneralChunkerConfigToForm(config);
case Operator.TitleChunker:
+ case Operator.ManualChunker:
return transformTitleChunkerConfigToForm(config);
default:
return config ?? {};
@@ -407,6 +408,13 @@ export function transformFormConfigToApi(
return transformGeneralChunkerParams(config as any);
case Operator.TitleChunker:
return transformTitleChunkerParams(config as any);
+ case Operator.ManualChunker:
+ // These fields are UI-only for the title chunker and are not read by
+ // the backend ManualChunker component (manual.go pins method=group,
+ // ignores the token cap).
+ return transformTitleChunkerParams(
+ omit(config, ['include_heading_content', 'chunk_token_cap']) as any,
+ );
default:
return config;
}
@@ -429,6 +437,7 @@ export function normalizeOperatorForm(
};
}
case Operator.TitleChunker:
+ case Operator.ManualChunker:
return {
...cloneDeep(initialTitleChunkerValues),
...rawForm,