feat: add RelevantForm #918 (#1344)

### What problem does this PR solve?

feat: add RelevantForm #918

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-07-03 10:15:19 +08:00
committed by GitHub
parent 25c4c717cb
commit a7423e3a94
13 changed files with 237 additions and 82 deletions

View File

@ -1,12 +1,24 @@
import LLMSelect from '@/components/llm-select';
import { useTranslate } from '@/hooks/commonHooks';
import { Form } from 'antd';
import { Form, Select } from 'antd';
import { Operator } from '../constant';
import {
useBuildFormSelectOptions,
useHandleFormSelectChange,
} from '../form-hooks';
import { useSetLlmSetting } from '../hooks';
import { IOperatorForm } from '../interface';
import { useWatchConnectionChanges } from './hooks';
const RelevantForm = ({ onValuesChange, form }: IOperatorForm) => {
const { t } = useTranslate('chat');
const RelevantForm = ({ onValuesChange, form, node }: IOperatorForm) => {
const { t } = useTranslate('flow');
useSetLlmSetting(form);
const buildRelevantOptions = useBuildFormSelectOptions(
Operator.Relevant,
node?.id,
);
useWatchConnectionChanges({ nodeId: node?.id, form });
const { handleSelectChange } = useHandleFormSelectChange(node?.id);
return (
<Form
@ -26,6 +38,20 @@ const RelevantForm = ({ onValuesChange, form }: IOperatorForm) => {
>
<LLMSelect></LLMSelect>
</Form.Item>
<Form.Item label={t('yes')} name={'yes'}>
<Select
allowClear
options={buildRelevantOptions([form?.getFieldValue('no')])}
onChange={handleSelectChange('yes')}
/>
</Form.Item>
<Form.Item label={t('no')} name={'no'}>
<Select
allowClear
options={buildRelevantOptions([form?.getFieldValue('yes')])}
onChange={handleSelectChange('no')}
/>
</Form.Item>
</Form>
);
};