Fix: Fix the issue of errors when creating datasets. (#13787)

### What problem does this PR solve?

Fix: Fix the issue of errors when creating datasets.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: Jin Hai <haijin.chn@gmail.com>
Co-authored-by: Yingfeng <yingfeng.zhang@gmail.com>
This commit is contained in:
balibabu
2026-03-25 21:37:58 +08:00
committed by GitHub
parent 8f45398422
commit 33948b9dd8
2 changed files with 11 additions and 9 deletions

View File

@ -60,7 +60,7 @@ interface IProps {
name?: string;
}
export function ChunkMethodItem(props: IProps) {
const { line } = props;
const { line, name = 'parser_id' } = props;
const { t } = useTranslate('knowledgeConfiguration');
const form = useFormContext();
// const handleChunkMethodSelectChange = useHandleChunkMethodSelectChange(form);
@ -69,7 +69,7 @@ export function ChunkMethodItem(props: IProps) {
return (
<FormField
control={form.control}
name={'parser_id'}
name={name}
render={({ field }) => (
<FormItem className=" items-center space-y-1">
<div className={line === 1 ? 'flex items-center' : ''}>

View File

@ -21,6 +21,7 @@ import { FormLayout } from '@/constants/form';
import { useFetchTenantInfo } from '@/hooks/use-user-setting-request';
import { IModalProps } from '@/interfaces/common';
import { zodResolver } from '@hookform/resolvers/zod';
import { omit } from 'lodash';
import { useEffect } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
@ -87,18 +88,17 @@ export function InputForm({ onOk }: IModalProps<any>) {
},
});
function onSubmit(data: z.infer<typeof FormSchema>) {
console.log('submit', data);
onOk?.(data);
}
const parseType = useWatch({
control: form.control,
name: 'parseType',
});
function onSubmit(data: z.infer<typeof FormSchema>) {
const nextData = parseType === 1 ? data : omit(data, 'chunk_method');
onOk?.(nextData);
}
useEffect(() => {
console.log('parseType', parseType);
if (parseType === 1) {
form.setValue('pipeline_id', '');
}
@ -133,7 +133,9 @@ export function InputForm({ onOk }: IModalProps<any>) {
<EmbeddingModelItem line={2} isEdit={false} />
<ParseTypeItem />
{parseType === 1 && <ChunkMethodItem></ChunkMethodItem>}
{parseType === 1 && (
<ChunkMethodItem name="chunk_method"></ChunkMethodItem>
)}
{parseType === 2 && (
<DataFlowSelect
isMult={false}