File size: 4,487 Bytes
af3ef26
 
 
6b8fc2c
 
af3ef26
 
 
 
6b8fc2c
 
af3ef26
 
 
 
 
 
6b8fc2c
af3ef26
 
 
 
 
 
 
 
6b8fc2c
af3ef26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b8fc2c
af3ef26
6b8fc2c
af3ef26
6b8fc2c
af3ef26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { Form, Modal, Select } from 'antd';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'umi';

type FieldType = {
  embd_id?: string;
  img2txt_id?: string;
  llm_id?: string;
  asr_id?: string;
};

const SsModal = () => {
  const dispatch = useDispatch();
  const settingModel = useSelector((state: any) => state.settingModel);
  const { isShowSSModal, llmInfo = {}, tenantIfo } = settingModel;
  const [form] = Form.useForm();
  const { t } = useTranslation();

  const handleCancel = () => {
    dispatch({
      type: 'settingModel/updateState',
      payload: {
        isShowSSModal: false,
      },
    });
  };

  const handleOk = async () => {
    try {
      const values = await form.validateFields();
      const retcode = await dispatch<any>({
        type: 'settingModel/set_tenant_info',
        payload: {
          ...values,
          tenant_id: tenantIfo.tenant_id,
        },
      });
      retcode === 0 &&
        dispatch({
          type: 'settingModel/updateState',
          payload: {
            isShowSSModal: false,
          },
        });
    } catch (errorInfo) {
      console.log('Failed:', errorInfo);
    }
  };

  const handleChange = () => {};

  return (
    <Modal
      title="Basic Modal"
      open={isShowSSModal}
      onOk={handleOk}
      onCancel={handleCancel}
    >
      <Form
        form={form}
        name="validateOnly"
        // labelCol={{ span: 8 }}
        // wrapperCol={{ span: 16 }}
        style={{ maxWidth: 600 }}
        autoComplete="off"
        layout="vertical"
      >
        <Form.Item<FieldType>
          label="embedding 模型"
          name="embd_id"
          rules={[{ required: true, message: 'Please input value' }]}
          initialValue={tenantIfo.embd_id}
        >
          <Select
            // style={{ width: 200 }}
            onChange={handleChange}
            // fieldNames={label:}
            options={Object.keys(llmInfo).map((t) => {
              const options = llmInfo[t]
                .filter((d: any) => d.model_type === 'embedding')
                .map((d: any) => ({ label: d.llm_name, value: d.llm_name }));
              return { label: t, options };
            })}
          />
        </Form.Item>
        <Form.Item<FieldType>
          label="chat 模型"
          name="llm_id"
          rules={[{ required: true, message: 'Please input value' }]}
          initialValue={tenantIfo.llm_id}
        >
          <Select
            // style={{ width: 200 }}
            onChange={handleChange}
            // fieldNames={label:}
            options={Object.keys(llmInfo).map((t) => {
              const options = llmInfo[t]
                .filter((d: any) => d.model_type === 'chat')
                .map((d: any) => ({ label: d.llm_name, value: d.llm_name }));
              return { label: t, options };
            })}
          />
        </Form.Item>
        <Form.Item<FieldType>
          label="image2text 模型"
          name="img2txt_id"
          rules={[{ required: true, message: 'Please input value' }]}
          initialValue={tenantIfo.img2txt_id}
        >
          <Select
            // style={{ width: 200 }}
            onChange={handleChange}
            // fieldNames={label:}
            options={Object.keys(llmInfo).map((t) => {
              const options = llmInfo[t]
                .filter((d: any) => d.model_type === 'image2text')
                .map((d: any) => ({ label: d.llm_name, value: d.llm_name }));
              return { label: t, options };
            })}
          />
        </Form.Item>
        <Form.Item<FieldType>
          label="speech2text 模型"
          name="asr_id"
          rules={[{ required: true, message: 'Please input value' }]}
          initialValue={tenantIfo.asr_id}
        >
          <Select
            // style={{ width: 200 }}
            onChange={handleChange}
            // fieldNames={label:}
            options={Object.keys(llmInfo).map((t) => {
              const options = llmInfo[t]
                .filter((d: any) => d.model_type === 'speech2text')
                .map((d: any) => ({ label: d.llm_name, value: d.llm_name }));
              return { label: t, options };
            })}
          />
        </Form.Item>
      </Form>
    </Modal>
  );
};
export default SsModal;