balibabu
commited on
Commit
·
63f5b44
1
Parent(s):
afe703e
feat: support AWS Bedrock #308 (#1617)
Browse files### What problem does this PR solve?
feat: support AWS Bedrock #308
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/locales/en.ts +14 -0
- web/src/locales/zh-traditional.ts +14 -0
- web/src/locales/zh.ts +14 -0
- web/src/pages/user-setting/setting-model/bedrock-modal/index.tsx +119 -0
- web/src/pages/user-setting/setting-model/constant.ts +33 -0
- web/src/pages/user-setting/setting-model/hooks.ts +29 -8
- web/src/pages/user-setting/setting-model/index.tsx +35 -44
- web/src/pages/user-setting/setting-model/{volcengine-model → volcengine-modal}/index.tsx +0 -0
web/src/locales/en.ts
CHANGED
@@ -492,6 +492,20 @@ The above is the content you need to summarize.`,
|
|
492 |
volcAKMessage: 'Please input your VOLC_ACCESS_KEY',
|
493 |
addVolcEngineSK: 'VOLC SECRET_KEY',
|
494 |
volcSKMessage: 'Please input your SECRET_KEY',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
},
|
496 |
message: {
|
497 |
registered: 'Registered!',
|
|
|
492 |
volcAKMessage: 'Please input your VOLC_ACCESS_KEY',
|
493 |
addVolcEngineSK: 'VOLC SECRET_KEY',
|
494 |
volcSKMessage: 'Please input your SECRET_KEY',
|
495 |
+
bedrockModelNameMessage: 'Please input your model name!',
|
496 |
+
addBedrockEngineAK: 'ACCESS KEY',
|
497 |
+
bedrockAKMessage: 'Please input your ACCESS KEY',
|
498 |
+
addBedrockSK: 'SECRET KEY',
|
499 |
+
bedrockSKMessage: 'Please input your SECRET KEY',
|
500 |
+
bedrockRegion: 'AWS Region',
|
501 |
+
bedrockRegionMessage: 'Please select!',
|
502 |
+
'us-east-1': 'US East (N. Virginia)',
|
503 |
+
'us-west-2': 'US West (Oregon)',
|
504 |
+
'ap-southeast-1': 'Asia Pacific (Singapore)',
|
505 |
+
'ap-northeast-1': 'Asia Pacific (Tokyo)',
|
506 |
+
'eu-central-1': 'Europe (Frankfurt)',
|
507 |
+
'us-gov-west-1': 'AWS GovCloud (US-West)',
|
508 |
+
'ap-southeast-2': 'Asia Pacific (Sydney)',
|
509 |
},
|
510 |
message: {
|
511 |
registered: 'Registered!',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -455,6 +455,20 @@ export default {
|
|
455 |
volcAKMessage: '請輸入VOLC_ACCESS_KEY',
|
456 |
addVolcEngineSK: '火山 SECRET_KEY',
|
457 |
volcSKMessage: '請輸入VOLC_SECRET_KEY',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
},
|
459 |
message: {
|
460 |
registered: '註冊成功',
|
|
|
455 |
volcAKMessage: '請輸入VOLC_ACCESS_KEY',
|
456 |
addVolcEngineSK: '火山 SECRET_KEY',
|
457 |
volcSKMessage: '請輸入VOLC_SECRET_KEY',
|
458 |
+
bedrockModelNameMessage: '請輸入名稱!',
|
459 |
+
addBedrockEngineAK: 'ACCESS KEY',
|
460 |
+
bedrockAKMessage: '請輸入 ACCESS KEY',
|
461 |
+
addBedrockSK: 'SECRET KEY',
|
462 |
+
bedrockSKMessage: '請輸入 SECRET KEY',
|
463 |
+
bedrockRegion: 'AWS Region',
|
464 |
+
bedrockRegionMessage: '請選擇!',
|
465 |
+
'us-east-1': '美國東部 (維吉尼亞北部)',
|
466 |
+
'us-west-2': '美國西部 (俄勒岡州)',
|
467 |
+
'ap-southeast-1': '亞太地區 (新加坡)',
|
468 |
+
'ap-northeast-1': '亞太地區 (東京)',
|
469 |
+
'eu-central-1': '歐洲 (法蘭克福)',
|
470 |
+
'us-gov-west-1': 'AWS GovCloud (US-West)',
|
471 |
+
'ap-southeast-2': '亞太地區 (雪梨)',
|
472 |
},
|
473 |
message: {
|
474 |
registered: '註冊成功',
|
web/src/locales/zh.ts
CHANGED
@@ -472,6 +472,20 @@ export default {
|
|
472 |
volcAKMessage: '请输入VOLC_ACCESS_KEY',
|
473 |
addVolcEngineSK: '火山 SECRET_KEY',
|
474 |
volcSKMessage: '请输入VOLC_SECRET_KEY',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
},
|
476 |
message: {
|
477 |
registered: '注册成功',
|
|
|
472 |
volcAKMessage: '请输入VOLC_ACCESS_KEY',
|
473 |
addVolcEngineSK: '火山 SECRET_KEY',
|
474 |
volcSKMessage: '请输入VOLC_SECRET_KEY',
|
475 |
+
bedrockModelNameMessage: '请输入名称!',
|
476 |
+
addBedrockEngineAK: 'ACCESS KEY',
|
477 |
+
bedrockAKMessage: '请输入 ACCESS KEY',
|
478 |
+
addBedrockSK: 'SECRET KEY',
|
479 |
+
bedrockSKMessage: '请输入 SECRET KEY',
|
480 |
+
bedrockRegion: 'AWS Region',
|
481 |
+
bedrockRegionMessage: '请选择!',
|
482 |
+
'us-east-1': '美国东部 (弗吉尼亚北部)',
|
483 |
+
'us-west-2': '美国西部 (俄勒冈州)',
|
484 |
+
'ap-southeast-1': '亚太地区 (新加坡)',
|
485 |
+
'ap-northeast-1': '亚太地区 (东京)',
|
486 |
+
'eu-central-1': '欧洲 (法兰克福)',
|
487 |
+
'us-gov-west-1': 'AWS GovCloud (US-West)',
|
488 |
+
'ap-southeast-2': '亚太地区 (悉尼)',
|
489 |
},
|
490 |
message: {
|
491 |
registered: '注册成功',
|
web/src/pages/user-setting/setting-model/bedrock-modal/index.tsx
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
+
import { IModalProps } from '@/interfaces/common';
|
3 |
+
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
4 |
+
import { Flex, Form, Input, Modal, Select, Space } from 'antd';
|
5 |
+
import { useMemo } from 'react';
|
6 |
+
import { BedrockRegionList } from '../constant';
|
7 |
+
|
8 |
+
type FieldType = IAddLlmRequestBody & {
|
9 |
+
bedrock_ak: string;
|
10 |
+
bedrock_sk: string;
|
11 |
+
bedrock_region: string;
|
12 |
+
};
|
13 |
+
|
14 |
+
const { Option } = Select;
|
15 |
+
|
16 |
+
const BedrockModal = ({
|
17 |
+
visible,
|
18 |
+
hideModal,
|
19 |
+
onOk,
|
20 |
+
loading,
|
21 |
+
llmFactory,
|
22 |
+
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
|
23 |
+
const [form] = Form.useForm<FieldType>();
|
24 |
+
|
25 |
+
const { t } = useTranslate('setting');
|
26 |
+
const options = useMemo(
|
27 |
+
() => BedrockRegionList.map((x) => ({ value: x, label: t(x) })),
|
28 |
+
[t],
|
29 |
+
);
|
30 |
+
|
31 |
+
const handleOk = async () => {
|
32 |
+
const values = await form.validateFields();
|
33 |
+
|
34 |
+
const data = {
|
35 |
+
...values,
|
36 |
+
llm_factory: llmFactory,
|
37 |
+
};
|
38 |
+
|
39 |
+
onOk?.(data);
|
40 |
+
};
|
41 |
+
|
42 |
+
return (
|
43 |
+
<Modal
|
44 |
+
title={t('addLlmTitle', { name: llmFactory })}
|
45 |
+
open={visible}
|
46 |
+
onOk={handleOk}
|
47 |
+
onCancel={hideModal}
|
48 |
+
okButtonProps={{ loading }}
|
49 |
+
footer={(originNode: React.ReactNode) => {
|
50 |
+
return (
|
51 |
+
<Flex justify={'space-between'}>
|
52 |
+
<a
|
53 |
+
href="https://console.aws.amazon.com/"
|
54 |
+
target="_blank"
|
55 |
+
rel="noreferrer"
|
56 |
+
>
|
57 |
+
{t('ollamaLink', { name: llmFactory })}
|
58 |
+
</a>
|
59 |
+
<Space>{originNode}</Space>
|
60 |
+
</Flex>
|
61 |
+
);
|
62 |
+
}}
|
63 |
+
>
|
64 |
+
<Form
|
65 |
+
name="basic"
|
66 |
+
style={{ maxWidth: 600 }}
|
67 |
+
autoComplete="off"
|
68 |
+
layout={'vertical'}
|
69 |
+
form={form}
|
70 |
+
>
|
71 |
+
<Form.Item<FieldType>
|
72 |
+
label={t('modelType')}
|
73 |
+
name="model_type"
|
74 |
+
initialValue={'chat'}
|
75 |
+
rules={[{ required: true, message: t('modelTypeMessage') }]}
|
76 |
+
>
|
77 |
+
<Select placeholder={t('modelTypeMessage')}>
|
78 |
+
<Option value="chat">chat</Option>
|
79 |
+
<Option value="embedding">embedding</Option>
|
80 |
+
</Select>
|
81 |
+
</Form.Item>
|
82 |
+
<Form.Item<FieldType>
|
83 |
+
label={t('modelName')}
|
84 |
+
name="llm_name"
|
85 |
+
rules={[{ required: true, message: t('bedrockModelNameMessage') }]}
|
86 |
+
>
|
87 |
+
<Input placeholder={t('bedrockModelNameMessage')} />
|
88 |
+
</Form.Item>
|
89 |
+
<Form.Item<FieldType>
|
90 |
+
label={t('addBedrockEngineAK')}
|
91 |
+
name="bedrock_ak"
|
92 |
+
rules={[{ required: true, message: t('bedrockAKMessage') }]}
|
93 |
+
>
|
94 |
+
<Input placeholder={t('bedrockAKMessage')} />
|
95 |
+
</Form.Item>
|
96 |
+
<Form.Item<FieldType>
|
97 |
+
label={t('addBedrockSK')}
|
98 |
+
name="bedrock_sk"
|
99 |
+
rules={[{ required: true, message: t('bedrockSKMessage') }]}
|
100 |
+
>
|
101 |
+
<Input placeholder={t('bedrockSKMessage')} />
|
102 |
+
</Form.Item>
|
103 |
+
<Form.Item<FieldType>
|
104 |
+
label={t('bedrockRegion')}
|
105 |
+
name="bedrock_region"
|
106 |
+
rules={[{ required: true, message: t('bedrockRegionMessage') }]}
|
107 |
+
>
|
108 |
+
<Select
|
109 |
+
placeholder={t('bedrockRegionMessage')}
|
110 |
+
options={options}
|
111 |
+
allowClear
|
112 |
+
></Select>
|
113 |
+
</Form.Item>
|
114 |
+
</Form>
|
115 |
+
</Modal>
|
116 |
+
);
|
117 |
+
};
|
118 |
+
|
119 |
+
export default BedrockModal;
|
web/src/pages/user-setting/setting-model/constant.ts
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Please lowercase the file name
|
2 |
+
export const IconMap = {
|
3 |
+
'Tongyi-Qianwen': 'tongyi',
|
4 |
+
Moonshot: 'moonshot',
|
5 |
+
OpenAI: 'openai',
|
6 |
+
'ZHIPU-AI': 'zhipu',
|
7 |
+
文心一言: 'wenxin',
|
8 |
+
Ollama: 'ollama',
|
9 |
+
Xinference: 'xinference',
|
10 |
+
DeepSeek: 'deepseek',
|
11 |
+
VolcEngine: 'volc_engine',
|
12 |
+
BaiChuan: 'baichuan',
|
13 |
+
Jina: 'jina',
|
14 |
+
MiniMax: 'chat-minimax',
|
15 |
+
Mistral: 'mistral',
|
16 |
+
'Azure-OpenAI': 'azure',
|
17 |
+
Bedrock: 'bedrock',
|
18 |
+
Gemini: 'gemini',
|
19 |
+
Groq: 'groq-next',
|
20 |
+
OpenRouter: 'open-router',
|
21 |
+
LocalAI: 'local-ai',
|
22 |
+
StepFun: 'stepfun',
|
23 |
+
};
|
24 |
+
|
25 |
+
export const BedrockRegionList = [
|
26 |
+
'us-east-1',
|
27 |
+
'us-west-2',
|
28 |
+
'ap-southeast-1',
|
29 |
+
'ap-northeast-1',
|
30 |
+
'eu-central-1',
|
31 |
+
'us-gov-west-1',
|
32 |
+
'ap-southeast-2',
|
33 |
+
];
|
web/src/pages/user-setting/setting-model/hooks.ts
CHANGED
@@ -168,7 +168,6 @@ export const useSubmitOllama = () => {
|
|
168 |
|
169 |
export const useSubmitVolcEngine = () => {
|
170 |
const loading = useOneNamespaceEffectsLoading('settingModel', ['add_llm']);
|
171 |
-
const [selectedVolcFactory, setSelectedVolcFactory] = useState<string>('');
|
172 |
const addLlm = useAddLlm();
|
173 |
const {
|
174 |
visible: volcAddingVisible,
|
@@ -186,18 +185,40 @@ export const useSubmitVolcEngine = () => {
|
|
186 |
[hideVolcAddingModal, addLlm],
|
187 |
);
|
188 |
|
189 |
-
const handleShowVolcAddingModal = (llmFactory: string) => {
|
190 |
-
setSelectedVolcFactory(llmFactory);
|
191 |
-
showVolcAddingModal();
|
192 |
-
};
|
193 |
-
|
194 |
return {
|
195 |
volcAddingLoading: loading,
|
196 |
onVolcAddingOk,
|
197 |
volcAddingVisible,
|
198 |
hideVolcAddingModal,
|
199 |
-
showVolcAddingModal
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
};
|
202 |
};
|
203 |
|
|
|
168 |
|
169 |
export const useSubmitVolcEngine = () => {
|
170 |
const loading = useOneNamespaceEffectsLoading('settingModel', ['add_llm']);
|
|
|
171 |
const addLlm = useAddLlm();
|
172 |
const {
|
173 |
visible: volcAddingVisible,
|
|
|
185 |
[hideVolcAddingModal, addLlm],
|
186 |
);
|
187 |
|
|
|
|
|
|
|
|
|
|
|
188 |
return {
|
189 |
volcAddingLoading: loading,
|
190 |
onVolcAddingOk,
|
191 |
volcAddingVisible,
|
192 |
hideVolcAddingModal,
|
193 |
+
showVolcAddingModal,
|
194 |
+
};
|
195 |
+
};
|
196 |
+
|
197 |
+
export const useSubmitBedrock = () => {
|
198 |
+
const loading = useOneNamespaceEffectsLoading('settingModel', ['add_llm']);
|
199 |
+
const addLlm = useAddLlm();
|
200 |
+
const {
|
201 |
+
visible: bedrockAddingVisible,
|
202 |
+
hideModal: hideBedrockAddingModal,
|
203 |
+
showModal: showBedrockAddingModal,
|
204 |
+
} = useSetModalState();
|
205 |
+
|
206 |
+
const onBedrockAddingOk = useCallback(
|
207 |
+
async (payload: IAddLlmRequestBody) => {
|
208 |
+
const ret = await addLlm(payload);
|
209 |
+
if (ret === 0) {
|
210 |
+
hideBedrockAddingModal();
|
211 |
+
}
|
212 |
+
},
|
213 |
+
[hideBedrockAddingModal, addLlm],
|
214 |
+
);
|
215 |
+
|
216 |
+
return {
|
217 |
+
bedrockAddingLoading: loading,
|
218 |
+
onBedrockAddingOk,
|
219 |
+
bedrockAddingVisible,
|
220 |
+
hideBedrockAddingModal,
|
221 |
+
showBedrockAddingModal,
|
222 |
};
|
223 |
};
|
224 |
|
web/src/pages/user-setting/setting-model/index.tsx
CHANGED
@@ -28,14 +28,17 @@ import {
|
|
28 |
Tooltip,
|
29 |
Typography,
|
30 |
} from 'antd';
|
31 |
-
import { useCallback } from 'react';
|
32 |
import SettingTitle from '../components/setting-title';
|
33 |
import { isLocalLlmFactory } from '../utils';
|
34 |
import ApiKeyModal from './api-key-modal';
|
|
|
|
|
35 |
import {
|
36 |
useHandleDeleteLlm,
|
37 |
useSelectModelProvidersLoading,
|
38 |
useSubmitApiKey,
|
|
|
39 |
useSubmitOllama,
|
40 |
useSubmitSystemModelSetting,
|
41 |
useSubmitVolcEngine,
|
@@ -43,31 +46,7 @@ import {
|
|
43 |
import styles from './index.less';
|
44 |
import OllamaModal from './ollama-modal';
|
45 |
import SystemModelSettingModal from './system-model-setting-modal';
|
46 |
-
import VolcEngineModal from './volcengine-
|
47 |
-
|
48 |
-
// Please lowercase the file name
|
49 |
-
const IconMap = {
|
50 |
-
'Tongyi-Qianwen': 'tongyi',
|
51 |
-
Moonshot: 'moonshot',
|
52 |
-
OpenAI: 'openai',
|
53 |
-
'ZHIPU-AI': 'zhipu',
|
54 |
-
文心一言: 'wenxin',
|
55 |
-
Ollama: 'ollama',
|
56 |
-
Xinference: 'xinference',
|
57 |
-
DeepSeek: 'deepseek',
|
58 |
-
VolcEngine: 'volc_engine',
|
59 |
-
BaiChuan: 'baichuan',
|
60 |
-
Jina: 'jina',
|
61 |
-
MiniMax: 'chat-minimax',
|
62 |
-
Mistral: 'mistral',
|
63 |
-
'Azure-OpenAI': 'azure',
|
64 |
-
Bedrock: 'bedrock',
|
65 |
-
Gemini: 'gemini',
|
66 |
-
Groq: 'groq-next',
|
67 |
-
OpenRouter: 'open-router',
|
68 |
-
LocalAI:'local-ai',
|
69 |
-
StepFun:'stepfun'
|
70 |
-
};
|
71 |
|
72 |
const LlmIcon = ({ name }: { name: string }) => {
|
73 |
const icon = IconMap[name as keyof typeof IconMap];
|
@@ -188,32 +167,37 @@ const UserSettingModel = () => {
|
|
188 |
showVolcAddingModal,
|
189 |
onVolcAddingOk,
|
190 |
volcAddingLoading,
|
191 |
-
selectedVolcFactory,
|
192 |
} = useSubmitVolcEngine();
|
193 |
|
194 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
(llmFactory: string) => {
|
196 |
if (isLocalLlmFactory(llmFactory)) {
|
197 |
showLlmAddingModal(llmFactory);
|
198 |
-
} else if (llmFactory
|
199 |
-
|
200 |
} else {
|
201 |
showApiKeyModal({ llm_factory: llmFactory });
|
202 |
}
|
203 |
},
|
204 |
-
[showApiKeyModal, showLlmAddingModal,
|
205 |
);
|
206 |
|
207 |
-
const handleAddModel = (llmFactory: string) => () => {
|
208 |
-
if (isLocalLlmFactory(llmFactory)) {
|
209 |
-
showLlmAddingModal(llmFactory);
|
210 |
-
} else if (llmFactory === 'VolcEngine') {
|
211 |
-
showVolcAddingModal('VolcEngine');
|
212 |
-
} else {
|
213 |
-
handleApiKeyClick(llmFactory);
|
214 |
-
}
|
215 |
-
};
|
216 |
-
|
217 |
const items: CollapseProps['items'] = [
|
218 |
{
|
219 |
key: '1',
|
@@ -223,7 +207,7 @@ const UserSettingModel = () => {
|
|
223 |
grid={{ gutter: 16, column: 1 }}
|
224 |
dataSource={llmList}
|
225 |
renderItem={(item) => (
|
226 |
-
<ModelCard item={item} clickApiKey={
|
227 |
)}
|
228 |
/>
|
229 |
),
|
@@ -254,7 +238,7 @@ const UserSettingModel = () => {
|
|
254 |
</Flex>
|
255 |
</Flex>
|
256 |
<Divider></Divider>
|
257 |
-
<Button type="link" onClick={handleAddModel(item.name)}>
|
258 |
{t('addTheModel')}
|
259 |
</Button>
|
260 |
</Card>
|
@@ -305,8 +289,15 @@ const UserSettingModel = () => {
|
|
305 |
hideModal={hideVolcAddingModal}
|
306 |
onOk={onVolcAddingOk}
|
307 |
loading={volcAddingLoading}
|
308 |
-
llmFactory={
|
309 |
></VolcEngineModal>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
</section>
|
311 |
);
|
312 |
};
|
|
|
28 |
Tooltip,
|
29 |
Typography,
|
30 |
} from 'antd';
|
31 |
+
import { useCallback, useMemo } from 'react';
|
32 |
import SettingTitle from '../components/setting-title';
|
33 |
import { isLocalLlmFactory } from '../utils';
|
34 |
import ApiKeyModal from './api-key-modal';
|
35 |
+
import BedrockModal from './bedrock-modal';
|
36 |
+
import { IconMap } from './constant';
|
37 |
import {
|
38 |
useHandleDeleteLlm,
|
39 |
useSelectModelProvidersLoading,
|
40 |
useSubmitApiKey,
|
41 |
+
useSubmitBedrock,
|
42 |
useSubmitOllama,
|
43 |
useSubmitSystemModelSetting,
|
44 |
useSubmitVolcEngine,
|
|
|
46 |
import styles from './index.less';
|
47 |
import OllamaModal from './ollama-modal';
|
48 |
import SystemModelSettingModal from './system-model-setting-modal';
|
49 |
+
import VolcEngineModal from './volcengine-modal';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
const LlmIcon = ({ name }: { name: string }) => {
|
52 |
const icon = IconMap[name as keyof typeof IconMap];
|
|
|
167 |
showVolcAddingModal,
|
168 |
onVolcAddingOk,
|
169 |
volcAddingLoading,
|
|
|
170 |
} = useSubmitVolcEngine();
|
171 |
|
172 |
+
const {
|
173 |
+
bedrockAddingLoading,
|
174 |
+
onBedrockAddingOk,
|
175 |
+
bedrockAddingVisible,
|
176 |
+
hideBedrockAddingModal,
|
177 |
+
showBedrockAddingModal,
|
178 |
+
} = useSubmitBedrock();
|
179 |
+
|
180 |
+
const ModalMap = useMemo(
|
181 |
+
() => ({
|
182 |
+
Bedrock: showBedrockAddingModal,
|
183 |
+
VolcEngine: showVolcAddingModal,
|
184 |
+
}),
|
185 |
+
[showBedrockAddingModal, showVolcAddingModal],
|
186 |
+
);
|
187 |
+
|
188 |
+
const handleAddModel = useCallback(
|
189 |
(llmFactory: string) => {
|
190 |
if (isLocalLlmFactory(llmFactory)) {
|
191 |
showLlmAddingModal(llmFactory);
|
192 |
+
} else if (llmFactory in ModalMap) {
|
193 |
+
ModalMap[llmFactory as keyof typeof ModalMap]();
|
194 |
} else {
|
195 |
showApiKeyModal({ llm_factory: llmFactory });
|
196 |
}
|
197 |
},
|
198 |
+
[showApiKeyModal, showLlmAddingModal, ModalMap],
|
199 |
);
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
const items: CollapseProps['items'] = [
|
202 |
{
|
203 |
key: '1',
|
|
|
207 |
grid={{ gutter: 16, column: 1 }}
|
208 |
dataSource={llmList}
|
209 |
renderItem={(item) => (
|
210 |
+
<ModelCard item={item} clickApiKey={handleAddModel}></ModelCard>
|
211 |
)}
|
212 |
/>
|
213 |
),
|
|
|
238 |
</Flex>
|
239 |
</Flex>
|
240 |
<Divider></Divider>
|
241 |
+
<Button type="link" onClick={() => handleAddModel(item.name)}>
|
242 |
{t('addTheModel')}
|
243 |
</Button>
|
244 |
</Card>
|
|
|
289 |
hideModal={hideVolcAddingModal}
|
290 |
onOk={onVolcAddingOk}
|
291 |
loading={volcAddingLoading}
|
292 |
+
llmFactory={'VolcEngine'}
|
293 |
></VolcEngineModal>
|
294 |
+
<BedrockModal
|
295 |
+
visible={bedrockAddingVisible}
|
296 |
+
hideModal={hideBedrockAddingModal}
|
297 |
+
onOk={onBedrockAddingOk}
|
298 |
+
loading={bedrockAddingLoading}
|
299 |
+
llmFactory={'Bedrock'}
|
300 |
+
></BedrockModal>
|
301 |
</section>
|
302 |
);
|
303 |
};
|
web/src/pages/user-setting/setting-model/{volcengine-model → volcengine-modal}/index.tsx
RENAMED
File without changes
|