Feat: Create empty agent #3221 (#8054)

### What problem does this PR solve?

Feat: Create empty agent #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-06-05 12:04:31 +08:00
committed by GitHub
parent 4f3abb855a
commit c163b799d2
9 changed files with 281 additions and 67 deletions

View File

@ -191,7 +191,6 @@ const BeginForm = ({ node }: INextOperatorForm) => {
{visible && (
<ParameterDialog
visible={visible}
hideModal={hideModal}
initialValue={currentRecord}
onOk={ok}

View File

@ -19,6 +19,7 @@ import { RAGFlowSelect, RAGFlowSelectOptionType } from '@/components/ui/select';
import { Switch } from '@/components/ui/switch';
import { IModalProps } from '@/interfaces/common';
import { zodResolver } from '@hookform/resolvers/zod';
import { isEmpty } from 'lodash';
import { useEffect, useMemo } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
@ -60,11 +61,13 @@ function ParameterForm({
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
mode: 'onChange',
defaultValues: {
type: BeginQueryType.Line,
optional: false,
key: '',
name: '',
options: [],
},
});
@ -98,10 +101,12 @@ function ParameterForm({
});
useEffect(() => {
form.reset({
...initialValue,
options: initialValue.options?.map((x) => ({ value: x })),
});
if (!isEmpty(initialValue)) {
form.reset({
...initialValue,
options: initialValue.options?.map((x) => ({ value: x })),
});
}
}, [form, initialValue]);
function onSubmit(data: z.infer<typeof FormSchema>) {