diff --git a/src/apis/index.ts b/src/apis/index.ts index 530a741cfaa0e2f40bd4f0340fb64d15a2512767..32242d5598cd7a2e44d10954b6f04ba8405bc3d9 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -15,6 +15,8 @@ import { knowledgeApi, appApi, apiApi, + modelApi, + mcpApi, } from './paths'; import { workFlowApi } from './workFlow'; import { appCenterApi } from './appCenter'; @@ -29,4 +31,6 @@ export const api = { ...workFlowApi, ...appApi, ...apiApi, + ...modelApi, + ...mcpApi, }; diff --git a/src/apis/paths/apikey.ts b/src/apis/paths/apikey.ts index 6ffdb0c64c85f936f7de85111d709fd2dde562a4..0e7498ccfd113f45c52df839702b308c54ab3516 100644 --- a/src/apis/paths/apikey.ts +++ b/src/apis/paths/apikey.ts @@ -19,7 +19,7 @@ export const getApiKey = (): Promise< any, ( | FcResponse<{ - api_key: string; + api_key_exists: string; }> | undefined ), @@ -32,11 +32,10 @@ export const getApiKey = (): Promise< * USER登录 * @returns */ -export const changeApiKey = (params: { - action: string; - query?: string; -}): Promise<[any, FcResponse | undefined]> => { - return post('/api/auth/key', params, params); +export const changeApiKey = (params: { action: string; query?: string }) => { + return post<{ + api_key: string; + }>('/api/auth/key', params, params); }; export const apiKeyApi = { diff --git a/src/apis/paths/model.ts b/src/apis/paths/model.ts new file mode 100644 index 0000000000000000000000000000000000000000..35f61f7fba683f62f93d76a1f32c950667e19f29 --- /dev/null +++ b/src/apis/paths/model.ts @@ -0,0 +1,92 @@ +import { get, post, del } from '../server'; + +enum Provider { + OLLAMA = 'Ollama', + VLLM = 'VLLM', + QWEN = 'Tongyi-Qianwen', + XUNFEI = 'XunFei Spark', + BAICHUAN = 'BaiChuan', + BAIDU = 'BaiduYiyan', + MODELSCOPE = 'ModelScope', +} + +/** + * 获取用户的模型列表 + * @returns + */ +const getUserModelList = () => { + return get<{ + models: { + modelId: string; + icon: string; + description: string; + name: string; + model: string; + url: string; + provider: string; + maxTokens: number; + apiKey: string; + }[]; + totalModels: number; + }>('/api/model'); +}; + +/** + * 获取模型提供商列表 + * @returns + */ +const getModelProviderList = () => { + return get<{ + providers: { + providerId: string; + icon: string; + url: string; + description: string; + name: string; + }[]; + totalProviders: number; + }>('/api/model/provider'); +}; + +const getAllModels = (searchKey: string) => { + return get<{ + models: { modelId: string; modelName: string }[]; + }>('/api/model/all', { + searchKey, + }); +}; + +/** + * 添加模型 + * @param params + * @returns + */ +const createModel = (params: { + modelId?: string; + name: string; + provider: string; + icon?: string; + apiKey: string; + maxTokens: string; + model: string; + url: string; +}) => { + return post('/api/model', params); +}; + +/** + * 删除模型 + * @param modelId + * @returns + */ +const deleteModel = (modelId: string) => { + return del(`/api/model/${modelId}`); +}; + +export const modelApi = { + getUserModelList, + getModelProviderList, + createModel, + getAllModels, + deleteModel, +}; diff --git a/src/router/index.ts b/src/router/index.ts index 5c5fb4a833b4559ccd2456f736660c7f3ad28924..59be4cbdf11f68df9c390cd14d2cde15bf0a1460 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -49,6 +49,11 @@ const staticRoutes: Array = [ component: (): Promise => import('src/views/tools/index.vue'), }, + { + path: '/settings', + name: 'settings', + component: () => import('src/views/settings/index.vue'), + }, ], }, { diff --git a/src/views/dialogue/components/DialogueSession.vue b/src/views/dialogue/components/DialogueSession.vue index 205810db515f6a861c4a0d7b151a878cac045ce5..99acf1dfdeccc0818d6d80cd44ed5bc6724ad10e 100644 --- a/src/views/dialogue/components/DialogueSession.vue +++ b/src/views/dialogue/components/DialogueSession.vue @@ -987,7 +987,7 @@ button[disabled]:hover { top: 0; left: 0; opacity: 0.4; - background-image: linear-gradient(180deg, #e7f0fd 1%, #accbee 100%); + // background-image: linear-gradient(180deg, #e7f0fd 1%, #accbee 100%); z-index: -1; } diff --git a/src/views/dialogue/dialogueView.vue b/src/views/dialogue/dialogueView.vue index f7d65ca6411b3d5aa7f3c8f3c0ce4ba2a1344300..86a4137a35406ccb5703a552450c19ffda88b0c4 100644 --- a/src/views/dialogue/dialogueView.vue +++ b/src/views/dialogue/dialogueView.vue @@ -13,15 +13,17 @@ import { ElMessage } from 'element-plus'; import { watch } from 'vue'; import i18n from 'src/i18n'; import { reactive } from 'vue'; -import { useRouter } from 'vue-router'; +import { useRouter, useRoute } from 'vue-router'; import CopilotIcon from '@/assets/svgs/routerCopilot.svg'; import CopilotIconSelected from '@/assets/svgs/routerCopilotSelected.svg'; -import ApiIcon from '@/assets/svgs/routerApi.svg'; -import ApiIconSelected from '@/assets/svgs/routerApiSelected.svg'; +import PluginCenter from '@/assets/svgs/plugin_center.svg'; +import PluginCenterSelected from '@/assets/svgs/plugin_center_active.svg'; import AppIcon from '@/assets/svgs/routerApp.svg'; import AppIconSelected from '@/assets/svgs/routerAppSelected.svg'; import WitChainDIcon from '@/assets/svgs/witChainD.svg'; import WitChainDIconSelected from '@/assets/svgs/witChainDSelected.svg'; +import Setting from '@/assets/svgs/setting.svg'; +import SettingSelected from '@/assets/svgs/setting_active.svg'; import tools from '../tools/index.vue'; import TitleBar from './components/TitleBar.vue'; @@ -42,6 +44,7 @@ const revoke = ref(true); const isSubmitDisabled = ref(true); const ruleFormRef = ref(); const router = useRouter(); +const route = useRoute(); const type = import.meta.env.VITE_USER_TYPE; let routerList: ComputedRef< Array<{ @@ -63,10 +66,10 @@ let routerList: ComputedRef< anotherName: 'copilot', }, { - name: i18n.global.t('menu.semantic_center'), + name: i18n.global.t('menu.plugin_center'), path: '/api', - src: ApiIcon, - selectedSrc: ApiIconSelected, + src: PluginCenter, + selectedSrc: PluginCenterSelected, routerName: 'api', }, { @@ -166,8 +169,13 @@ const changeLanguagefun = (lang: 'CN' | 'EN') => { // 同步语言到iframe const iframe = document.querySelector('#my-iframe'); if (iframe?.contentWindow) { - const data = { lang: localStorage.getItem('localeLang') ?? 'CN' ,type: 'changeLanguage'}; - let target = window.location.origin.includes('localhost')?'http://localhost:3002/witchaind/' : `${window.location.origin}/witchaind/`; + const data = { + lang: localStorage.getItem('localeLang') ?? 'CN', + type: 'changeLanguage', + }; + let target = window.location.origin.includes('localhost') + ? 'http://localhost:3002/witchaind/' + : `${window.location.origin}/witchaind/`; iframe.contentWindow.postMessage(data, target); } }; @@ -177,10 +185,10 @@ const handleFormValidate = (prop: any, isValid: boolean, message: string) => { }; onMounted(() => { if (localStorage.getItem('theme')) { - document.body.setAttribute( - 'theme', - localStorage.getItem('theme') || 'light', - ); + // document.body.setAttribute( + // 'theme', + // localStorage.getItem('theme') || 'light', + // ); } if (localStorage.getItem('kb_id')) { ruleForm.kb_id = localStorage.getItem('kb_id'); @@ -256,37 +264,54 @@ watch(
- +
+ + + + + + + + {{ item.name }} + +
+ + - + - - {{ item.name }} + {{ i18n.global.t('menu.settings') }}
- +
diff --git a/src/views/settings/ApiKey.vue b/src/views/settings/ApiKey.vue new file mode 100644 index 0000000000000000000000000000000000000000..496d3f194df520d90e2e0080de822034a5877312 --- /dev/null +++ b/src/views/settings/ApiKey.vue @@ -0,0 +1,210 @@ + + + + + + diff --git a/src/views/settings/Model.vue b/src/views/settings/Model.vue new file mode 100644 index 0000000000000000000000000000000000000000..9e63951d617f47add7726e146a2cf6b1019c6785 --- /dev/null +++ b/src/views/settings/Model.vue @@ -0,0 +1,169 @@ + + + diff --git a/src/views/settings/components/AddModel.vue b/src/views/settings/components/AddModel.vue new file mode 100644 index 0000000000000000000000000000000000000000..45eb882ba6c249ac20f505f040a659e34dd22015 --- /dev/null +++ b/src/views/settings/components/AddModel.vue @@ -0,0 +1,224 @@ + + + + diff --git a/src/views/settings/components/ModelCard.vue b/src/views/settings/components/ModelCard.vue new file mode 100644 index 0000000000000000000000000000000000000000..b91a4a994cde27f26f29f91542a96d4132c7d338 --- /dev/null +++ b/src/views/settings/components/ModelCard.vue @@ -0,0 +1,108 @@ + + + diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..b4d51073e8dabf0283cd62df7fe14beef4b0c5ec --- /dev/null +++ b/src/views/settings/index.vue @@ -0,0 +1,80 @@ + + + + + +