File size: 1,491 Bytes
ab2ded1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import LLMSelect from '@/components/llm-select';
import { useTranslate } from '@/hooks/common-hooks';
import { Form, Select } from 'antd';
import { Operator } from '../constant';
import { useBuildFormSelectOptions } from '../form-hooks';
import { useSetLlmSetting } from '../hooks';
import { IOperatorForm } from '../interface';
import { useWatchConnectionChanges } from './hooks';

const RelevantForm = ({ onValuesChange, form, node }: IOperatorForm) => {
  const { t } = useTranslate('flow');
  useSetLlmSetting(form);
  const buildRelevantOptions = useBuildFormSelectOptions(
    Operator.Relevant,
    node?.id,
  );
  useWatchConnectionChanges({ nodeId: node?.id, form });

  return (
    <Form
      name="basic"
      labelCol={{ span: 4 }}
      wrapperCol={{ span: 20 }}
      onValuesChange={onValuesChange}
      autoComplete="off"
      form={form}
    >
      <Form.Item
        name={'llm_id'}
        label={t('model', { keyPrefix: 'chat' })}
        tooltip={t('modelTip', { keyPrefix: 'chat' })}
      >
        <LLMSelect></LLMSelect>
      </Form.Item>
      <Form.Item label={t('yes')} name={'yes'}>
        <Select
          allowClear
          options={buildRelevantOptions([form?.getFieldValue('no')])}
        />
      </Form.Item>
      <Form.Item label={t('no')} name={'no'}>
        <Select
          allowClear
          options={buildRelevantOptions([form?.getFieldValue('yes')])}
        />
      </Form.Item>
    </Form>
  );
};

export default RelevantForm;