feat(dataset): Added data pipeline configuration functionality #9869 (#10132)

### What problem does this PR solve?

feat(dataset): Added data pipeline configuration functionality #9869

- Added a data pipeline selection component to link data pipelines with
knowledge bases
- Added file filtering functionality, supporting custom file filtering
rules
- Optimized the configuration interface layout, adjusting style and
spacing
- Introduced new icons and buttons to enhance the user experience

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
chanx
2025-09-18 09:31:57 +08:00
committed by GitHub
parent a7abc57f68
commit e82617f6de
25 changed files with 397 additions and 134 deletions

View File

@ -1,4 +1,4 @@
import { DataFlowItem } from '@/components/data-pipeline-select';
import { DataFlowSelect } from '@/components/data-pipeline-select';
import { ButtonLoading } from '@/components/ui/button';
import {
Dialog,
@ -23,6 +23,7 @@ import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
import {
ChunkMethodItem,
EmbeddingModelItem,
ParseTypeItem,
} from '../dataset/dataset-setting/configuration/common-item';
@ -32,32 +33,68 @@ const FormId = 'dataset-creating-form';
export function InputForm({ onOk }: IModalProps<any>) {
const { t } = useTranslation();
const FormSchema = z.object({
name: z
.string()
.min(1, {
message: t('knowledgeList.namePlaceholder'),
})
.trim(),
parseType: z.number().optional(),
});
const FormSchema = z
.object({
name: z
.string()
.min(1, {
message: t('knowledgeList.namePlaceholder'),
})
.trim(),
parseType: z.number().optional(),
embd_id: z
.string()
.min(1, {
message: t('knowledgeConfiguration.embeddingModelPlaceholder'),
})
.trim(),
parser_id: z.string().optional(),
pipline_id: z.string().optional(),
})
.superRefine((data, ctx) => {
// When parseType === 1, parser_id is required
if (
data.parseType === 1 &&
(!data.parser_id || data.parser_id.trim() === '')
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: t('knowledgeList.parserRequired'),
path: ['parser_id'],
});
}
console.log('form-data', data);
// When parseType === 1, pipline_id required
if (data.parseType === 2 && !data.pipline_id) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: t('knowledgeList.dataFlowRequired'),
path: ['pipline_id'],
});
}
});
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
name: '',
parseType: 1,
parser_id: '',
embd_id: '',
},
});
function onSubmit(data: z.infer<typeof FormSchema>) {
onOk?.(data.name);
console.log('submit', data);
onOk?.(data);
}
const parseType = useWatch({
control: form.control,
name: 'parseType',
});
const { navigateToAgents } = useNavigatePage();
return (
<Form {...form}>
<form
@ -84,13 +121,19 @@ export function InputForm({ onOk }: IModalProps<any>) {
</FormItem>
)}
/>
<EmbeddingModelItem line={2} />
<EmbeddingModelItem line={2} isEdit={false} />
<ParseTypeItem />
{parseType === 1 && (
<>
<ChunkMethodItem></ChunkMethodItem>
</>
)}
{parseType === 2 && (
<>
<DataFlowItem
<DataFlowSelect
isMult={false}
toDataPipeline={navigateToAgents}
formFieldName="data_flow"
formFieldName="pipline_id"
/>
</>
)}
@ -108,7 +151,7 @@ export function DatasetCreatingDialog({
return (
<Dialog open onOpenChange={hideModal}>
<DialogContent className="sm:max-w-[425px]">
<DialogContent className="sm:max-w-[425px] focus-visible:!outline-none">
<DialogHeader>
<DialogTitle>{t('knowledgeList.createKnowledgeBase')}</DialogTitle>
</DialogHeader>