balibabu
commited on
Commit
·
7ccbbf8
1
Parent(s):
c1bdfb8
feat: add SystemModelSettingModal (#127)
Browse files* feat: add the model
* feat: add SystemModelSettingModal
- web/src/assets/svg/more-model.svg +14 -0
- web/src/hooks/commonHooks.ts +5 -1
- web/src/hooks/llmHooks.ts +35 -9
- web/src/pages/setting/model.ts +3 -1
- web/src/pages/user-setting/components/setting-title/index.tsx +21 -6
- web/src/pages/user-setting/setting-model/api-key-modal/index.tsx +1 -1
- web/src/pages/user-setting/setting-model/hooks.ts +58 -2
- web/src/pages/user-setting/setting-model/index.less +17 -0
- web/src/pages/user-setting/setting-model/index.tsx +96 -46
- web/src/pages/user-setting/setting-model/system-model-setting-modal/index.tsx +61 -0
web/src/assets/svg/more-model.svg
ADDED
|
web/src/hooks/commonHooks.ts
CHANGED
@@ -11,7 +11,11 @@ export const useSetModalState = () => {
|
|
11 |
setVisible(false);
|
12 |
};
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
};
|
16 |
|
17 |
export const useDeepCompareEffect = (
|
|
|
11 |
setVisible(false);
|
12 |
};
|
13 |
|
14 |
+
const switchVisible = () => {
|
15 |
+
setVisible(!visible);
|
16 |
+
};
|
17 |
+
|
18 |
+
return { visible, showModal, hideModal, switchVisible };
|
19 |
};
|
20 |
|
21 |
export const useDeepCompareEffect = (
|
web/src/hooks/llmHooks.ts
CHANGED
@@ -7,7 +7,7 @@ import {
|
|
7 |
import { useCallback, useEffect, useMemo } from 'react';
|
8 |
import { useDispatch, useSelector } from 'umi';
|
9 |
|
10 |
-
export const useFetchLlmList = (modelType
|
11 |
const dispatch = useDispatch();
|
12 |
|
13 |
const fetchLlmList = useCallback(() => {
|
@@ -85,19 +85,20 @@ export const useFetchLlmFactoryListOnMount = () => {
|
|
85 |
return list;
|
86 |
};
|
87 |
|
|
|
|
|
88 |
export const useFetchMyLlmListOnMount = () => {
|
89 |
const dispatch = useDispatch();
|
90 |
const llmList = useSelectMyLlmList();
|
91 |
const factoryList = useSelectLlmFactoryList();
|
92 |
|
93 |
-
const list: Array<
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
}, [llmList, factoryList]);
|
101 |
|
102 |
const fetchMyLlmList = useCallback(() => {
|
103 |
dispatch({
|
@@ -135,3 +136,28 @@ export const useSaveApiKey = () => {
|
|
135 |
|
136 |
return saveApiKey;
|
137 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
import { useCallback, useEffect, useMemo } from 'react';
|
8 |
import { useDispatch, useSelector } from 'umi';
|
9 |
|
10 |
+
export const useFetchLlmList = (modelType?: LlmModelType) => {
|
11 |
const dispatch = useDispatch();
|
12 |
|
13 |
const fetchLlmList = useCallback(() => {
|
|
|
85 |
return list;
|
86 |
};
|
87 |
|
88 |
+
export type LlmItem = { name: string; logo: string } & IMyLlmValue;
|
89 |
+
|
90 |
export const useFetchMyLlmListOnMount = () => {
|
91 |
const dispatch = useDispatch();
|
92 |
const llmList = useSelectMyLlmList();
|
93 |
const factoryList = useSelectLlmFactoryList();
|
94 |
|
95 |
+
const list: Array<LlmItem> = useMemo(() => {
|
96 |
+
return Object.entries(llmList).map(([key, value]) => ({
|
97 |
+
name: key,
|
98 |
+
logo: factoryList.find((x) => x.name === key)?.logo ?? '',
|
99 |
+
...value,
|
100 |
+
}));
|
101 |
+
}, [llmList, factoryList]);
|
|
|
102 |
|
103 |
const fetchMyLlmList = useCallback(() => {
|
104 |
dispatch({
|
|
|
136 |
|
137 |
return saveApiKey;
|
138 |
};
|
139 |
+
|
140 |
+
export interface ISystemModelSettingSavingParams {
|
141 |
+
tenant_id: string;
|
142 |
+
name?: string;
|
143 |
+
asr_id: string;
|
144 |
+
embd_id: string;
|
145 |
+
img2txt_id: string;
|
146 |
+
llm_id: string;
|
147 |
+
}
|
148 |
+
|
149 |
+
export const useSaveTenantInfo = () => {
|
150 |
+
const dispatch = useDispatch();
|
151 |
+
|
152 |
+
const saveTenantInfo = useCallback(
|
153 |
+
(savingParams: ISystemModelSettingSavingParams) => {
|
154 |
+
return dispatch<any>({
|
155 |
+
type: 'settingModel/set_tenant_info',
|
156 |
+
payload: savingParams,
|
157 |
+
});
|
158 |
+
},
|
159 |
+
[dispatch],
|
160 |
+
);
|
161 |
+
|
162 |
+
return saveTenantInfo;
|
163 |
+
};
|
web/src/pages/setting/model.ts
CHANGED
@@ -142,7 +142,7 @@ const model: DvaModel<SettingModelState> = {
|
|
142 |
}
|
143 |
},
|
144 |
*my_llm({ payload = {} }, { call, put }) {
|
145 |
-
const { data } = yield call(userService.my_llm
|
146 |
const { retcode, data: res } = data;
|
147 |
if (retcode === 0) {
|
148 |
yield put({
|
@@ -158,6 +158,8 @@ const model: DvaModel<SettingModelState> = {
|
|
158 |
const { retcode } = data;
|
159 |
if (retcode === 0) {
|
160 |
message.success('Modified!');
|
|
|
|
|
161 |
yield put({
|
162 |
type: 'updateState',
|
163 |
});
|
|
|
142 |
}
|
143 |
},
|
144 |
*my_llm({ payload = {} }, { call, put }) {
|
145 |
+
const { data } = yield call(userService.my_llm);
|
146 |
const { retcode, data: res } = data;
|
147 |
if (retcode === 0) {
|
148 |
yield put({
|
|
|
158 |
const { retcode } = data;
|
159 |
if (retcode === 0) {
|
160 |
message.success('Modified!');
|
161 |
+
yield put({ type: 'my_llm' });
|
162 |
+
yield put({ type: 'factories_list' });
|
163 |
yield put({
|
164 |
type: 'updateState',
|
165 |
});
|
web/src/pages/user-setting/components/setting-title/index.tsx
CHANGED
@@ -1,18 +1,33 @@
|
|
1 |
-
import {
|
|
|
2 |
|
3 |
const { Title, Paragraph } = Typography;
|
4 |
|
5 |
interface IProps {
|
6 |
title: string;
|
7 |
description: string;
|
|
|
|
|
8 |
}
|
9 |
|
10 |
-
const SettingTitle = ({
|
|
|
|
|
|
|
|
|
|
|
11 |
return (
|
12 |
-
<
|
13 |
-
<
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
);
|
17 |
};
|
18 |
|
|
|
1 |
+
import { SettingOutlined } from '@ant-design/icons';
|
2 |
+
import { Button, Flex, Typography } from 'antd';
|
3 |
|
4 |
const { Title, Paragraph } = Typography;
|
5 |
|
6 |
interface IProps {
|
7 |
title: string;
|
8 |
description: string;
|
9 |
+
showRightButton?: boolean;
|
10 |
+
clickButton?: () => void;
|
11 |
}
|
12 |
|
13 |
+
const SettingTitle = ({
|
14 |
+
title,
|
15 |
+
description,
|
16 |
+
clickButton,
|
17 |
+
showRightButton = false,
|
18 |
+
}: IProps) => {
|
19 |
return (
|
20 |
+
<Flex align="center" justify={'space-between'}>
|
21 |
+
<div>
|
22 |
+
<Title level={5}>{title}</Title>
|
23 |
+
<Paragraph>{description}</Paragraph>
|
24 |
+
</div>
|
25 |
+
{showRightButton && (
|
26 |
+
<Button type={'primary'} onClick={clickButton}>
|
27 |
+
<SettingOutlined></SettingOutlined> System Model Settings
|
28 |
+
</Button>
|
29 |
+
)}
|
30 |
+
</Flex>
|
31 |
);
|
32 |
};
|
33 |
|
web/src/pages/user-setting/setting-model/api-key-modal/index.tsx
CHANGED
@@ -64,7 +64,7 @@ const ApiKeyModal = ({
|
|
64 |
form={form}
|
65 |
>
|
66 |
<Form.Item<FieldType>
|
67 |
-
label="Api
|
68 |
name="api_key"
|
69 |
rules={[{ required: true, message: 'Please input api key!' }]}
|
70 |
>
|
|
|
64 |
form={form}
|
65 |
>
|
66 |
<Form.Item<FieldType>
|
67 |
+
label="Api-Key"
|
68 |
name="api_key"
|
69 |
rules={[{ required: true, message: 'Please input api key!' }]}
|
70 |
>
|
web/src/pages/user-setting/setting-model/hooks.ts
CHANGED
@@ -1,6 +1,16 @@
|
|
1 |
import { useSetModalState } from '@/hooks/commonHooks';
|
2 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
|
|
|
|
|
|
|
|
4 |
import { useCallback, useState } from 'react';
|
5 |
|
6 |
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
@@ -20,7 +30,7 @@ export const useSubmitApiKey = () => {
|
|
20 |
async (apiKey: string) => {
|
21 |
const ret = await saveApiKey({ ...savingParams, api_key: apiKey });
|
22 |
|
23 |
-
if (ret
|
24 |
hideApiKeyModal();
|
25 |
}
|
26 |
},
|
@@ -48,3 +58,49 @@ export const useSubmitApiKey = () => {
|
|
48 |
showApiKeyModal: onShowApiKeyModal,
|
49 |
};
|
50 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import { useSetModalState } from '@/hooks/commonHooks';
|
2 |
+
import {
|
3 |
+
IApiKeySavingParams,
|
4 |
+
ISystemModelSettingSavingParams,
|
5 |
+
useFetchLlmList,
|
6 |
+
useSaveApiKey,
|
7 |
+
useSaveTenantInfo,
|
8 |
+
} from '@/hooks/llmHooks';
|
9 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
10 |
+
import {
|
11 |
+
useFetchTenantInfo,
|
12 |
+
useSelectTenantInfo,
|
13 |
+
} from '@/hooks/userSettingHook';
|
14 |
import { useCallback, useState } from 'react';
|
15 |
|
16 |
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
|
|
30 |
async (apiKey: string) => {
|
31 |
const ret = await saveApiKey({ ...savingParams, api_key: apiKey });
|
32 |
|
33 |
+
if (ret === 0) {
|
34 |
hideApiKeyModal();
|
35 |
}
|
36 |
},
|
|
|
58 |
showApiKeyModal: onShowApiKeyModal,
|
59 |
};
|
60 |
};
|
61 |
+
|
62 |
+
export const useSubmitSystemModelSetting = () => {
|
63 |
+
const systemSetting = useSelectTenantInfo();
|
64 |
+
const loading = useOneNamespaceEffectsLoading('settingModel', [
|
65 |
+
'set_tenant_info',
|
66 |
+
]);
|
67 |
+
const saveSystemModelSetting = useSaveTenantInfo();
|
68 |
+
const {
|
69 |
+
visible: systemSettingVisible,
|
70 |
+
hideModal: hideSystemSettingModal,
|
71 |
+
showModal: showSystemSettingModal,
|
72 |
+
} = useSetModalState();
|
73 |
+
|
74 |
+
const onSystemSettingSavingOk = useCallback(
|
75 |
+
async (
|
76 |
+
payload: Omit<ISystemModelSettingSavingParams, 'tenant_id' | 'name'>,
|
77 |
+
) => {
|
78 |
+
const ret = await saveSystemModelSetting({
|
79 |
+
tenant_id: systemSetting.tenant_id,
|
80 |
+
name: systemSetting.name,
|
81 |
+
...payload,
|
82 |
+
});
|
83 |
+
|
84 |
+
if (ret === 0) {
|
85 |
+
hideSystemSettingModal();
|
86 |
+
}
|
87 |
+
},
|
88 |
+
[hideSystemSettingModal, saveSystemModelSetting, systemSetting],
|
89 |
+
);
|
90 |
+
|
91 |
+
return {
|
92 |
+
saveSystemModelSettingLoading: loading,
|
93 |
+
onSystemSettingSavingOk,
|
94 |
+
systemSettingVisible,
|
95 |
+
hideSystemSettingModal,
|
96 |
+
showSystemSettingModal,
|
97 |
+
};
|
98 |
+
};
|
99 |
+
|
100 |
+
export const useFetchSystemModelSettingOnMount = () => {
|
101 |
+
const systemSetting = useSelectTenantInfo();
|
102 |
+
useFetchLlmList();
|
103 |
+
useFetchTenantInfo();
|
104 |
+
|
105 |
+
return systemSetting;
|
106 |
+
};
|
web/src/pages/user-setting/setting-model/index.less
CHANGED
@@ -3,4 +3,21 @@
|
|
3 |
.factoryOperationWrapper {
|
4 |
text-align: right;
|
5 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
|
|
3 |
.factoryOperationWrapper {
|
4 |
text-align: right;
|
5 |
}
|
6 |
+
.modelItem {
|
7 |
+
}
|
8 |
+
.llmList {
|
9 |
+
padding-top: 10px;
|
10 |
+
}
|
11 |
+
.toBeAddedCard {
|
12 |
+
border-radius: 24px;
|
13 |
+
border: 1px solid #eaecf0;
|
14 |
+
background: #e3f0ff;
|
15 |
+
box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
|
16 |
+
}
|
17 |
+
.addedCard {
|
18 |
+
border-radius: 18px;
|
19 |
+
border: 1px solid #eaecf0;
|
20 |
+
background: #e6e7eb;
|
21 |
+
box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
|
22 |
+
}
|
23 |
}
|
web/src/pages/user-setting/setting-model/index.tsx
CHANGED
@@ -1,4 +1,7 @@
|
|
|
|
|
|
1 |
import {
|
|
|
2 |
useFetchLlmFactoryListOnMount,
|
3 |
useFetchMyLlmListOnMount,
|
4 |
} from '@/hooks/llmHooks';
|
@@ -13,14 +16,74 @@ import {
|
|
13 |
List,
|
14 |
Row,
|
15 |
Space,
|
16 |
-
|
17 |
} from 'antd';
|
|
|
18 |
import SettingTitle from '../components/setting-title';
|
19 |
import ApiKeyModal from './api-key-modal';
|
20 |
-
import { useSubmitApiKey } from './hooks';
|
|
|
21 |
|
22 |
import styles from './index.less';
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
const UserSettingModel = () => {
|
25 |
const factoryList = useFetchLlmFactoryListOnMount();
|
26 |
const llmList = useFetchMyLlmListOnMount();
|
@@ -32,9 +95,23 @@ const UserSettingModel = () => {
|
|
32 |
hideApiKeyModal,
|
33 |
showApiKeyModal,
|
34 |
} = useSubmitApiKey();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
const
|
37 |
-
|
38 |
};
|
39 |
|
40 |
return (
|
@@ -43,48 +120,15 @@ const UserSettingModel = () => {
|
|
43 |
<SettingTitle
|
44 |
title="Model Setting"
|
45 |
description="Manage your account settings and preferences here."
|
|
|
|
|
46 |
></SettingTitle>
|
47 |
<Divider></Divider>
|
48 |
<List
|
49 |
grid={{ gutter: 16, column: 1 }}
|
50 |
dataSource={llmList}
|
51 |
renderItem={(item) => (
|
52 |
-
<
|
53 |
-
<Card>
|
54 |
-
<Row align={'middle'}>
|
55 |
-
<Col span={12}>
|
56 |
-
<Flex gap={'middle'} align="center">
|
57 |
-
<Avatar shape="square" size="large" src={item.logo} />
|
58 |
-
<Flex vertical gap={'small'}>
|
59 |
-
<b>{item.name}</b>
|
60 |
-
<div>
|
61 |
-
{item.tags.split(',').map((x) => (
|
62 |
-
<Tag key={x}>{x}</Tag>
|
63 |
-
))}
|
64 |
-
</div>
|
65 |
-
</Flex>
|
66 |
-
</Flex>
|
67 |
-
</Col>
|
68 |
-
<Col span={12} className={styles.factoryOperationWrapper}>
|
69 |
-
<Space size={'middle'}>
|
70 |
-
<Button onClick={handleApiKeyClick(item.name)}>
|
71 |
-
API-Key
|
72 |
-
<SettingOutlined />
|
73 |
-
</Button>
|
74 |
-
<Button>
|
75 |
-
Show more models
|
76 |
-
<SettingOutlined />
|
77 |
-
</Button>
|
78 |
-
</Space>
|
79 |
-
</Col>
|
80 |
-
</Row>
|
81 |
-
<List
|
82 |
-
size="small"
|
83 |
-
dataSource={item.llm}
|
84 |
-
renderItem={(item) => <List.Item>{item.name}</List.Item>}
|
85 |
-
/>
|
86 |
-
</Card>
|
87 |
-
</List.Item>
|
88 |
)}
|
89 |
/>
|
90 |
<p>Models to be added</p>
|
@@ -101,18 +145,18 @@ const UserSettingModel = () => {
|
|
101 |
dataSource={factoryList}
|
102 |
renderItem={(item) => (
|
103 |
<List.Item>
|
104 |
-
<Card>
|
105 |
<Flex vertical gap={'large'}>
|
106 |
<Avatar shape="square" size="large" src={item.logo} />
|
107 |
<Flex vertical gap={'middle'}>
|
108 |
<b>{item.name}</b>
|
109 |
-
<
|
110 |
-
{item.tags.split(',').map((x) => (
|
111 |
-
<Tag key={x}>{x}</Tag>
|
112 |
-
))}
|
113 |
-
</Space>
|
114 |
</Flex>
|
115 |
</Flex>
|
|
|
|
|
|
|
|
|
116 |
</Card>
|
117 |
</List.Item>
|
118 |
)}
|
@@ -125,6 +169,12 @@ const UserSettingModel = () => {
|
|
125 |
initialValue={initialApiKey}
|
126 |
onOk={onApiKeySavingOk}
|
127 |
></ApiKeyModal>
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
</>
|
129 |
);
|
130 |
};
|
|
|
1 |
+
import { ReactComponent as MoreModelIcon } from '@/assets/svg/more-model.svg';
|
2 |
+
import { useSetModalState } from '@/hooks/commonHooks';
|
3 |
import {
|
4 |
+
LlmItem,
|
5 |
useFetchLlmFactoryListOnMount,
|
6 |
useFetchMyLlmListOnMount,
|
7 |
} from '@/hooks/llmHooks';
|
|
|
16 |
List,
|
17 |
Row,
|
18 |
Space,
|
19 |
+
Typography,
|
20 |
} from 'antd';
|
21 |
+
import { useCallback } from 'react';
|
22 |
import SettingTitle from '../components/setting-title';
|
23 |
import ApiKeyModal from './api-key-modal';
|
24 |
+
import { useSubmitApiKey, useSubmitSystemModelSetting } from './hooks';
|
25 |
+
import SystemModelSettingModal from './system-model-setting-modal';
|
26 |
|
27 |
import styles from './index.less';
|
28 |
|
29 |
+
const { Text } = Typography;
|
30 |
+
interface IModelCardProps {
|
31 |
+
item: LlmItem;
|
32 |
+
clickApiKey: (llmFactory: string) => void;
|
33 |
+
}
|
34 |
+
|
35 |
+
const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
36 |
+
const { visible, switchVisible } = useSetModalState();
|
37 |
+
|
38 |
+
const handleApiKeyClick = () => {
|
39 |
+
clickApiKey(item.name);
|
40 |
+
};
|
41 |
+
|
42 |
+
const handleShowMoreClick = () => {
|
43 |
+
switchVisible();
|
44 |
+
};
|
45 |
+
|
46 |
+
return (
|
47 |
+
<List.Item>
|
48 |
+
<Card className={styles.addedCard}>
|
49 |
+
<Row align={'middle'}>
|
50 |
+
<Col span={12}>
|
51 |
+
<Flex gap={'middle'} align="center">
|
52 |
+
<Avatar shape="square" size="large" src={item.logo} />
|
53 |
+
<Flex vertical gap={'small'}>
|
54 |
+
<b>{item.name}</b>
|
55 |
+
<Text>{item.tags}</Text>
|
56 |
+
</Flex>
|
57 |
+
</Flex>
|
58 |
+
</Col>
|
59 |
+
<Col span={12} className={styles.factoryOperationWrapper}>
|
60 |
+
<Space size={'middle'}>
|
61 |
+
<Button onClick={handleApiKeyClick}>
|
62 |
+
API-Key
|
63 |
+
<SettingOutlined />
|
64 |
+
</Button>
|
65 |
+
<Button onClick={handleShowMoreClick}>
|
66 |
+
<Flex gap={'small'}>
|
67 |
+
Show more models
|
68 |
+
<MoreModelIcon />
|
69 |
+
</Flex>
|
70 |
+
</Button>
|
71 |
+
</Space>
|
72 |
+
</Col>
|
73 |
+
</Row>
|
74 |
+
{visible && (
|
75 |
+
<List
|
76 |
+
size="small"
|
77 |
+
dataSource={item.llm}
|
78 |
+
className={styles.llmList}
|
79 |
+
renderItem={(item) => <List.Item>{item.name}</List.Item>}
|
80 |
+
/>
|
81 |
+
)}
|
82 |
+
</Card>
|
83 |
+
</List.Item>
|
84 |
+
);
|
85 |
+
};
|
86 |
+
|
87 |
const UserSettingModel = () => {
|
88 |
const factoryList = useFetchLlmFactoryListOnMount();
|
89 |
const llmList = useFetchMyLlmListOnMount();
|
|
|
95 |
hideApiKeyModal,
|
96 |
showApiKeyModal,
|
97 |
} = useSubmitApiKey();
|
98 |
+
const {
|
99 |
+
saveSystemModelSettingLoading,
|
100 |
+
onSystemSettingSavingOk,
|
101 |
+
systemSettingVisible,
|
102 |
+
hideSystemSettingModal,
|
103 |
+
showSystemSettingModal,
|
104 |
+
} = useSubmitSystemModelSetting();
|
105 |
+
|
106 |
+
const handleApiKeyClick = useCallback(
|
107 |
+
(llmFactory: string) => {
|
108 |
+
showApiKeyModal({ llm_factory: llmFactory });
|
109 |
+
},
|
110 |
+
[showApiKeyModal],
|
111 |
+
);
|
112 |
|
113 |
+
const handleAddModel = (llmFactory: string) => () => {
|
114 |
+
handleApiKeyClick(llmFactory);
|
115 |
};
|
116 |
|
117 |
return (
|
|
|
120 |
<SettingTitle
|
121 |
title="Model Setting"
|
122 |
description="Manage your account settings and preferences here."
|
123 |
+
showRightButton
|
124 |
+
clickButton={showSystemSettingModal}
|
125 |
></SettingTitle>
|
126 |
<Divider></Divider>
|
127 |
<List
|
128 |
grid={{ gutter: 16, column: 1 }}
|
129 |
dataSource={llmList}
|
130 |
renderItem={(item) => (
|
131 |
+
<ModelCard item={item} clickApiKey={handleApiKeyClick}></ModelCard>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
)}
|
133 |
/>
|
134 |
<p>Models to be added</p>
|
|
|
145 |
dataSource={factoryList}
|
146 |
renderItem={(item) => (
|
147 |
<List.Item>
|
148 |
+
<Card className={styles.toBeAddedCard}>
|
149 |
<Flex vertical gap={'large'}>
|
150 |
<Avatar shape="square" size="large" src={item.logo} />
|
151 |
<Flex vertical gap={'middle'}>
|
152 |
<b>{item.name}</b>
|
153 |
+
<Text>{item.tags}</Text>
|
|
|
|
|
|
|
|
|
154 |
</Flex>
|
155 |
</Flex>
|
156 |
+
<Divider></Divider>
|
157 |
+
<Button type="link" onClick={handleAddModel(item.name)}>
|
158 |
+
Add the model
|
159 |
+
</Button>
|
160 |
</Card>
|
161 |
</List.Item>
|
162 |
)}
|
|
|
169 |
initialValue={initialApiKey}
|
170 |
onOk={onApiKeySavingOk}
|
171 |
></ApiKeyModal>
|
172 |
+
<SystemModelSettingModal
|
173 |
+
visible={systemSettingVisible}
|
174 |
+
onOk={onSystemSettingSavingOk}
|
175 |
+
hideModal={hideSystemSettingModal}
|
176 |
+
loading={saveSystemModelSettingLoading}
|
177 |
+
></SystemModelSettingModal>
|
178 |
</>
|
179 |
);
|
180 |
};
|
web/src/pages/user-setting/setting-model/system-model-setting-modal/index.tsx
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
2 |
+
import { ISystemModelSettingSavingParams } from '@/hooks/llmHooks';
|
3 |
+
import { Form, Modal, Select } from 'antd';
|
4 |
+
import { useEffect } from 'react';
|
5 |
+
import { useFetchSystemModelSettingOnMount } from '../hooks';
|
6 |
+
|
7 |
+
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
8 |
+
loading: boolean;
|
9 |
+
onOk: (
|
10 |
+
payload: Omit<ISystemModelSettingSavingParams, 'tenant_id' | 'name'>,
|
11 |
+
) => void;
|
12 |
+
}
|
13 |
+
|
14 |
+
const SystemModelSettingModal = ({
|
15 |
+
visible,
|
16 |
+
hideModal,
|
17 |
+
onOk,
|
18 |
+
loading,
|
19 |
+
}: IProps) => {
|
20 |
+
const [form] = Form.useForm();
|
21 |
+
const initialValues = useFetchSystemModelSettingOnMount();
|
22 |
+
|
23 |
+
const handleOk = async () => {
|
24 |
+
const values = await form.validateFields();
|
25 |
+
onOk(values);
|
26 |
+
};
|
27 |
+
|
28 |
+
useEffect(() => {
|
29 |
+
form.setFieldsValue(initialValues);
|
30 |
+
}, [form, initialValues]);
|
31 |
+
|
32 |
+
const onFormLayoutChange = () => {};
|
33 |
+
|
34 |
+
return (
|
35 |
+
<Modal
|
36 |
+
title="Basic Modal"
|
37 |
+
open={visible}
|
38 |
+
onOk={handleOk}
|
39 |
+
onCancel={hideModal}
|
40 |
+
okButtonProps={{ loading }}
|
41 |
+
confirmLoading={loading}
|
42 |
+
>
|
43 |
+
<Form form={form} onValuesChange={onFormLayoutChange} layout={'vertical'}>
|
44 |
+
<Form.Item label="sequence2txt model" name="asr_id">
|
45 |
+
<Select options={[{ value: 'sample', label: <span>sample</span> }]} />
|
46 |
+
</Form.Item>
|
47 |
+
<Form.Item label="Embedding model" name="embd_id">
|
48 |
+
<Select options={[{ value: 'sample', label: <span>sample</span> }]} />
|
49 |
+
</Form.Item>
|
50 |
+
<Form.Item label="img2txt_id model" name="img2txt_id">
|
51 |
+
<Select options={[{ value: 'sample', label: <span>sample</span> }]} />
|
52 |
+
</Form.Item>
|
53 |
+
<Form.Item label="Chat model" name="llm_id">
|
54 |
+
<Select options={[{ value: 'sample', label: <span>sample</span> }]} />
|
55 |
+
</Form.Item>
|
56 |
+
</Form>
|
57 |
+
</Modal>
|
58 |
+
);
|
59 |
+
};
|
60 |
+
|
61 |
+
export default SystemModelSettingModal;
|