diff --git a/ui/src/api/application/application-key.ts b/ui/src/api/application/application-key.ts new file mode 100644 index 000000000..81035bbb1 --- /dev/null +++ b/ui/src/api/application/application-key.ts @@ -0,0 +1,63 @@ +import { Result } from '@/request/Result' +import { get, post, del, put } from '@/request/index' + +import { type Ref } from 'vue' + +const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/application' + +/** + * API_KEY列表 + * @param 参数 application_id + */ +const getAPIKey: (application_id: string, loading?: Ref) => Promise> = ( + application_id, + loading, +) => { + return get(`${prefix}/${application_id}/application`, undefined, loading) +} + +/** + * 新增API_KEY + * @param 参数 application_id + */ +const postAPIKey: (application_id: string, loading?: Ref) => Promise> = ( + application_id, + loading, +) => { + return post(`${prefix}/${application_id}/application`, {}, undefined, loading) +} + +/** + * 删除API_KEY + * @param 参数 application_id api_key_id + */ +const delAPIKey: ( + application_id: string, + api_key_id: string, + loading?: Ref, +) => Promise> = (application_id, api_key_id, loading) => { + return del(`${prefix}/${application_id}/application/${api_key_id}`, undefined, undefined, loading) +} + +/** + * 修改API_KEY + * @param 参数 application_id,api_key_id + * data { + * is_active: boolean + * } + */ +const putAPIKey: ( + application_id: string, + api_key_id: string, + data: any, + loading?: Ref, +) => Promise> = (application_id, api_key_id, data, loading) => { + return put(`${prefix}/${application_id}/application/${api_key_id}`, data, undefined, loading) +} + +export default { + getAPIKey, + postAPIKey, + delAPIKey, + putAPIKey, +} diff --git a/ui/src/api/application/application-overview.ts b/ui/src/api/application/application-overview.ts deleted file mode 100644 index 6c3a0e373..000000000 --- a/ui/src/api/application/application-overview.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Result } from '@/request/Result' -import { get, post, del, put } from '@/request/index' - -import { type Ref } from 'vue' - -const prefix = '/application' - -/** - * API_KEY列表 - * @param 参数 application_id - */ -const getAPIKey: (application_id: string, loading?: Ref) => Promise> = ( - application_id, - loading -) => { - return get(`${prefix}/${application_id}/api_key`, undefined, loading) -} - -/** - * 新增API_KEY - * @param 参数 application_id - */ -const postAPIKey: (application_id: string, loading?: Ref) => Promise> = ( - application_id, - loading -) => { - return post(`${prefix}/${application_id}/api_key`, {}, undefined, loading) -} - -/** - * 删除API_KEY - * @param 参数 application_id api_key_id - */ -const delAPIKey: ( - application_id: string, - api_key_id: string, - loading?: Ref -) => Promise> = (application_id, api_key_id, loading) => { - return del(`${prefix}/${application_id}/api_key/${api_key_id}`, undefined, undefined, loading) -} - -/** - * 修改API_KEY - * @param 参数 application_id,api_key_id - * data { - * is_active: boolean - * } - */ -const putAPIKey: ( - application_id: string, - api_key_id: string, - data: any, - loading?: Ref -) => Promise> = (application_id, api_key_id, data, loading) => { - return put(`${prefix}/${application_id}/api_key/${api_key_id}`, data, undefined, loading) -} - -/** - * 统计 - * @param 参数 application_id, data - */ -const getStatistics: ( - application_id: string, - data: any, - loading?: Ref -) => Promise> = (application_id, data, loading) => { - return get(`${prefix}/${application_id}/statistics/chat_record_aggregate_trend`, data, loading) -} - -/** - * 修改应用icon - * @param 参数 application_id - * data: file - */ -const putAppIcon: ( - application_id: string, - data: any, - loading?: Ref -) => Promise> = (application_id, data, loading) => { - return put(`${prefix}/${application_id}/edit_icon`, data, undefined, loading) -} - -export default { - getAPIKey, - postAPIKey, - delAPIKey, - putAPIKey, - getStatistics, - putAppIcon -} diff --git a/ui/src/api/application/application.ts b/ui/src/api/application/application.ts index 3bbc8e2fe..256dd4c1d 100644 --- a/ui/src/api/application/application.ts +++ b/ui/src/api/application/application.ts @@ -1,9 +1,9 @@ -import {Result} from '@/request/Result' -import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index' -import type {pageRequest} from '@/api/type/common' -import type {ApplicationFormType} from '@/api/type/application' -import {type Ref} from 'vue' -import type {FormField} from '@/components/dynamics-form/type' +import { Result } from '@/request/Result' +import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index' +import type { pageRequest } from '@/api/type/common' +import type { ApplicationFormType } from '@/api/type/application' +import { type Ref } from 'vue' +import type { FormField } from '@/components/dynamics-form/type' const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/application' @@ -11,8 +11,11 @@ const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/applicat * 获取全部应用 * @param 参数 */ -const getAllApplication: () => Promise> = () => { - return get(`${prefix}`) +const getAllApplication: (param?: any, loading?: Ref) => Promise> = ( + param, + loading, +) => { + return get(`${prefix}`, param, loading) } /** @@ -26,11 +29,7 @@ const getApplication: ( param: any, loading?: Ref, ) => Promise> = (page, param, loading) => { - return get( - `${prefix}/${page.current_page}/${page.page_size}`, - param, - loading, - ) + return get(`${prefix}/${page.current_page}/${page.page_size}`, param, loading) } /** @@ -78,17 +77,6 @@ const getApplicationDetail: ( return get(`${prefix}/${application_id}`, undefined, loading) } -/** - * 获得当前应用可使用的知识库 - * @param 参数 application_id - */ -const getApplicationDataset: ( - application_id: string, - loading?: Ref, -) => Promise> = (application_id, loading) => { - return get(`${prefix}/${application_id}/list_dataset`, undefined, loading) -} - /** * 获取AccessToken * @param 参数 application_id @@ -116,406 +104,8 @@ const putAccessToken: ( } /** - * 应用认证 - * @param 参数 - { - "access_token": "string" - } + * 导出应用 */ -const postAppAuthentication: ( - access_token: string, - loading?: Ref, - authentication_value?: any, -) => Promise = (access_token, loading, authentication_value) => { - return post( - `${prefix}/authentication`, - {access_token: access_token, authentication_value}, - undefined, - loading, - ) -} - -/** - * 对话获取应用相关信息 - * @param 参数 - { - "access_token": "string" - } - */ -const getAppProfile: (loading?: Ref) => Promise = (loading) => { - return get(`${prefix}/profile`, undefined, loading) -} - -/** - * 获得临时回话Id - * @param 参数 - - } - */ -const postChatOpen: (data: ApplicationFormType) => Promise> = (data) => { - return post(`${prefix}/chat/open`, data) -} - -/** - * 获得工作流临时回话Id - * @param 参数 - - } - */ -const postWorkflowChatOpen: (data: ApplicationFormType) => Promise> = (data) => { - return post(`${prefix}/chat_workflow/open`, data) -} - -/** - * 正式回话Id - * @param 参数 - * { - "model_id": "string", - "multiple_rounds_dialogue": true, - "dataset_id_list": [ - "string" - ] - } - */ -const getChatOpen: (application_id: string) => Promise> = (application_id) => { - return get(`${prefix}/${application_id}/chat/open`) -} -/** - * 对话 - * @param 参数 - * chat_id: string - * data - */ -const postChatMessage: (chat_id: string, data: any) => Promise = (chat_id, data) => { - return postStream(`/api${prefix}/chat_message/${chat_id}`, data) -} - -/** - * 点赞、点踩 - * @param 参数 - * application_id : string; chat_id : string; chat_record_id : string - * { - "vote_status": "string", // -1 0 1 - } - */ -const putChatVote: ( - application_id: string, - chat_id: string, - chat_record_id: string, - vote_status: string, - loading?: Ref, -) => Promise = (application_id, chat_id, chat_record_id, vote_status, loading) => { - return put( - `${prefix}/${application_id}/chat/${chat_id}/chat_record/${chat_record_id}/vote`, - { - vote_status, - }, - undefined, - loading, - ) -} - -/** - * 命中测试列表 - * @param application_id - * @param loading - * @query { query_text: string, top_number: number, similarity: number } - * @returns - */ -const getApplicationHitTest: ( - application_id: string, - data: any, - loading?: Ref, -) => Promise>> = (application_id, data, loading) => { - return get(`${prefix}/${application_id}/hit_test`, data, loading) -} - -/** - * 获取当前用户可使用的模型列表 - * @param application_id - * @param loading - * @query { query_text: string, top_number: number, similarity: number } - * @returns - */ -const getApplicationModel: ( - application_id: string, - loading?: Ref, -) => Promise>> = (application_id, loading) => { - return get(`${prefix}/${application_id}/model`, loading) -} - -/** - * 获取当前用户可使用的模型列表 - * @param application_id - * @param loading - * @query { query_text: string, top_number: number, similarity: number } - * @returns - */ -const getApplicationRerankerModel: ( - application_id: string, - loading?: Ref, -) => Promise>> = (application_id, loading) => { - return get(`${prefix}/${application_id}/model`, {model_type: 'RERANKER'}, loading) -} - -/** - * 获取当前用户可使用的模型列表 - * @param application_id - * @param loading - * @query { query_text: string, top_number: number, similarity: number } - * @returns - */ -const getApplicationSTTModel: ( - application_id: string, - loading?: Ref, -) => Promise>> = (application_id, loading) => { - return get(`${prefix}/${application_id}/model`, {model_type: 'STT'}, loading) -} - -/** - * 获取当前用户可使用的模型列表 - * @param application_id - * @param loading - * @query { query_text: string, top_number: number, similarity: number } - * @returns - */ -const getApplicationTTSModel: ( - application_id: string, - loading?: Ref, -) => Promise>> = (application_id, loading) => { - return get(`${prefix}/${application_id}/model`, {model_type: 'TTS'}, loading) -} - -const getApplicationImageModel: ( - application_id: string, - loading?: Ref, -) => Promise>> = (application_id, loading) => { - return get(`${prefix}/${application_id}/model`, {model_type: 'IMAGE'}, loading) -} - -const getApplicationTTIModel: ( - application_id: string, - loading?: Ref, -) => Promise>> = (application_id, loading) => { - return get(`${prefix}/${application_id}/model`, {model_type: 'TTI'}, loading) -} - -/** - * 发布应用 - * @param 参数 - */ -const putPublishApplication: ( - application_id: string, - data: ApplicationFormType, - loading?: Ref, -) => Promise> = (application_id, data, loading) => { - return put(`${prefix}/${application_id}/publish`, data, undefined, loading) -} -/** - * 获取应用所属的函数库列表 - * @param application_id 应用id - * @param loading - * @returns - */ -const listFunctionLib: (application_id: string, loading?: Ref) => Promise> = ( - application_id, - loading, -) => { - return get(`${prefix}/${application_id}/function_lib`, undefined, loading) -} -/** - * 获取当前人的所有应用列表 - * @param application_id 应用id - * @param loading - * @returns - */ -export const getApplicationList: ( - application_id: string, - loading?: Ref, -) => Promise> = (application_id, loading) => { - return get(`${prefix}/${application_id}/application`, undefined, loading) -} -/** - * 获取应用所属的函数库 - * @param application_id - * @param function_lib_id - * @param loading - * @returns - */ -const getFunctionLib: ( - application_id: string, - function_lib_id: string, - loading?: Ref, -) => Promise> = (application_id, function_lib_id, loading) => { - return get(`${prefix}/${application_id}/function_lib/${function_lib_id}`, undefined, loading) -} - -const getMcpTools: (data: any, loading?: Ref) => Promise> = ( - data, - loading, -) => { - return get(`${prefix}/mcp_servers`, data, loading) -} - -const getApplicationById: ( - application_id: string, - app_id: string, - loading?: Ref, -) => Promise> = (application_id, app_id, loading) => { - return get(`${prefix}/${application_id}/application/${app_id}`, undefined, loading) -} -/** - * 获取模型参数表单 - * @param application_id 应用id - * @param model_id 模型id - * @param loading - * @returns - */ -const getModelParamsForm: ( - application_id: string, - model_id: string, - loading?: Ref, -) => Promise>> = (application_id, model_id, loading) => { - return get(`${prefix}/${application_id}/model_params_form/${model_id}`, undefined, loading) -} - -/** - * 上传文档图片附件 - */ -const uploadFile: ( - application_id: string, - chat_id: string, - data: any, - loading?: Ref, -) => Promise> = (application_id, chat_id, data, loading) => { - return post(`${prefix}/${application_id}/chat/${chat_id}/upload_file`, data, undefined, loading) -} - -/** - * 语音转文本 - */ -const postSpeechToText: ( - application_id: string, - data: any, - loading?: Ref, -) => Promise> = (application_id, data, loading) => { - return post(`${prefix}/${application_id}/speech_to_text`, data, undefined, loading) -} - -/** - * 文本转语音 - */ -const postTextToSpeech: ( - application_id: string, - data: any, - loading?: Ref, -) => Promise> = (application_id, data, loading) => { - return download(`${prefix}/${application_id}/text_to_speech`, 'post', data, undefined, loading) -} - -/** - * 播放测试文本 - */ -const playDemoText: ( - application_id: string, - data: any, - loading?: Ref, -) => Promise> = (application_id, data, loading) => { - return download(`${prefix}/${application_id}/play_demo_text`, 'post', data, undefined, loading) -} -/** - * 获取平台状态 - */ -const getPlatformStatus: (application_id: string) => Promise> = (application_id) => { - return get(`/platform/${application_id}/status`) -} -/** - * 获取平台配置 - */ -const getPlatformConfig: (application_id: string, type: string) => Promise> = ( - application_id, - type, -) => { - return get(`/platform/${application_id}/${type}`) -} -/** - * 更新平台配置 - */ -const updatePlatformConfig: ( - application_id: string, - type: string, - data: any, - loading?: Ref, -) => Promise> = (application_id, type, data, loading) => { - return post(`/platform/${application_id}/${type}`, data, undefined, loading) -} -/** - * 更新平台状态 - */ -const updatePlatformStatus: (application_id: string, data: any) => Promise> = ( - application_id, - data, -) => { - return post(`/platform/${application_id}/status`, data) -} -/** - * 验证密码 - */ -const validatePassword: ( - application_id: string, - password: string, - loading?: Ref, -) => Promise> = (application_id, password, loading) => { - return get(`/application/${application_id}/auth/${password}`, undefined, loading) -} - -/** - * workflow历史版本 - */ -const getWorkFlowVersion: ( - application_id: string, - loading?: Ref, -) => Promise> = (application_id, loading) => { - return get(`/application/${application_id}/work_flow_version`, undefined, loading) -} - -/** - * workflow历史版本详情 - */ -const getWorkFlowVersionDetail: ( - application_id: string, - application_version_id: string, - loading?: Ref, -) => Promise> = (application_id, application_version_id, loading) => { - return get( - `/application/${application_id}/work_flow_version/${application_version_id}`, - undefined, - loading, - ) -} -/** - * 修改workflow历史版本 - */ -const putWorkFlowVersion: ( - application_id: string, - application_version_id: string, - data: any, - loading?: Ref, -) => Promise> = (application_id, application_version_id, data, loading) => { - return put( - `/application/${application_id}/work_flow_version/${application_version_id}`, - data, - undefined, - loading, - ) -} - -const getUserList: (type: string, loading?: Ref) => Promise> = ( - type, - loading, -) => { - return get(`/user/list/${type}`, undefined, loading) -} const exportApplication = ( application_id: string, @@ -524,7 +114,7 @@ const exportApplication = ( ) => { return exportFile( application_name + '.mk', - `/application/${application_id}/export`, + `${prefix}/${application_id}/export`, undefined, loading, ) @@ -539,50 +129,29 @@ const importApplication: (data: any, loading?: Ref) => Promise { return post(`${prefix}/import`, data, undefined, loading) } + +/** + * 统计 + * @param 参数 application_id, data + */ +const getStatistics: ( + application_id: string, + data: any, + loading?: Ref, +) => Promise> = (application_id, data, loading) => { + return get(`${prefix}/${application_id}/application-stats`, data, loading) +} + export default { - getAllAppilcation: getAllApplication, + getAllApplication, getApplication, postApplication, putApplication, - postChatOpen, - getChatOpen, - postChatMessage, delApplication, getApplicationDetail, - getApplicationDataset, getAccessToken, putAccessToken, - postAppAuthentication, - getAppProfile, - putChatVote, - getApplicationHitTest, - getApplicationModel, - putPublishApplication, - postWorkflowChatOpen, - listFunctionLib, - getFunctionLib, - getModelParamsForm, - getApplicationRerankerModel, - getApplicationSTTModel, - getApplicationTTSModel, - getApplicationImageModel, - getApplicationTTIModel, - postSpeechToText, - postTextToSpeech, - getPlatformStatus, - getPlatformConfig, - updatePlatformConfig, - updatePlatformStatus, - validatePassword, - getWorkFlowVersion, - getWorkFlowVersionDetail, - putWorkFlowVersion, - playDemoText, - getUserList, - getApplicationList, - uploadFile, exportApplication, importApplication, - getApplicationById, - getMcpTools, + getStatistics, } diff --git a/ui/src/views/application-overview/component/APIKeyDialog.vue b/ui/src/views/application-overview/component/APIKeyDialog.vue index ae05231ba..950c862a6 100644 --- a/ui/src/views/application-overview/component/APIKeyDialog.vue +++ b/ui/src/views/application-overview/component/APIKeyDialog.vue @@ -61,7 +61,7 @@ import { ref, watch } from 'vue' import { useRoute } from 'vue-router' import { copyClick } from '@/utils/clipboard' -import overviewApi from '@/api/application/application-overview' +import applicationKeyApi from '@/api/application/application-key' import SettingAPIKeyDialog from './SettingAPIKeyDialog.vue' import { datetimeFormat } from '@/utils/time' import { MsgSuccess, MsgConfirm } from '@/utils/message' @@ -100,7 +100,7 @@ function deleteApiKey(row: any) { } ) .then(() => { - overviewApi.delAPIKey(id as string, row.id, loading).then(() => { + applicationKeyApi.delAPIKey(id as string, row.id, loading).then(() => { MsgSuccess(t('common.deleteSuccess')) getApiKeyList() }) @@ -115,7 +115,7 @@ function changeState(row: any) { const str = obj.is_active ? t('views.applicationOverview.appInfo.APIKeyDialog.enabledSuccess') : t('views.applicationOverview.appInfo.APIKeyDialog.disabledSuccess') - overviewApi + applicationKeyApi .putAPIKey(id as string, row.id, obj, loading) .then((res) => { MsgSuccess(str) @@ -128,7 +128,7 @@ function changeState(row: any) { } function createApiKey() { - overviewApi.postAPIKey(id as string, loading).then((res) => { + applicationKeyApi.postAPIKey(id as string, loading).then((res) => { getApiKeyList() }) } @@ -139,7 +139,7 @@ const open = () => { } function getApiKeyList() { - overviewApi.getAPIKey(id as string, loading).then((res) => { + applicationKeyApi.getAPIKey(id as string, loading).then((res) => { apiKey.value = res.data }) } diff --git a/ui/src/views/application-overview/component/EditAvatarDialog.vue b/ui/src/views/application-overview/component/EditAvatarDialog.vue index 56a33140a..28645a9a3 100644 --- a/ui/src/views/application-overview/component/EditAvatarDialog.vue +++ b/ui/src/views/application-overview/component/EditAvatarDialog.vue @@ -61,7 +61,7 @@ diff --git a/ui/src/views/application/ApplicationSetting.vue b/ui/src/views/application/ApplicationSetting.vue index b9b1df386..f200c4cd9 100644 --- a/ui/src/views/application/ApplicationSetting.vue +++ b/ui/src/views/application/ApplicationSetting.vue @@ -166,7 +166,7 @@
- {{ $t('views.application.form.relatedKnowledge.placeholder') }} @@ -177,7 +177,7 @@ :lg="12" :xl="12" class="mb-8" - v-for="(item, index) in applicationForm.dataset_id_list" + v-for="(item, index) in applicationForm.knowledge_id_list" :key="index" > @@ -540,8 +540,8 @@ const applicationForm = ref({ model_id: '', dialogue_number: 1, prologue: t('views.application.form.defaultPrologue'), - dataset_id_list: [], - dataset_setting: { + knowledge_id_list: [], + knowledge_setting: { top_n: 3, similarity: 0.6, max_paragraph_char_number: 5000, @@ -661,20 +661,20 @@ function refreshTTSForm(data: any) { } function removeDataset(id: any) { - if (applicationForm.value.dataset_id_list) { - applicationForm.value.dataset_id_list.splice( - applicationForm.value.dataset_id_list.indexOf(id), + if (applicationForm.value.knowledge_id_list) { + applicationForm.value.knowledge_id_list.splice( + applicationForm.value.knowledge_id_list.indexOf(id), 1, ) } } function addDataset(val: Array) { - applicationForm.value.dataset_id_list = val + applicationForm.value.knowledge_id_list = val } function openDatasetDialog() { - AddDatasetDialogRef.value.open(applicationForm.value.dataset_id_list) + AddDatasetDialogRef.value.open(applicationForm.value.knowledge_id_list) } function getDetail() {