From 112e4b568dbe727d213375f0195a2f3514706d40 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Thu, 30 Nov 2023 18:50:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=86=E4=BA=AB=E5=AF=B9=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/package.json | 1 + ui/src/api/application.ts | 97 +++++++++++++------ ui/src/components/ai-dialog/index.vue | 41 +++++--- ui/src/components/index.ts | 2 +- ui/src/router/index.ts | 7 +- ui/src/stores/modules/application.ts | 14 +++ ui/src/stores/modules/user.ts | 10 +- ui/src/utils/clipboard.ts | 15 +++ ui/src/utils/utils.ts | 1 + ui/src/views/application/AppOverview.vue | 9 +- .../application/components/EmbedDialog.vue | 20 ++-- ui/src/views/application/index.vue | 58 ++++++----- ui/src/views/chat/index.vue | 35 ++++++- 13 files changed, 224 insertions(+), 86 deletions(-) create mode 100644 ui/src/utils/clipboard.ts diff --git a/ui/package.json b/ui/package.json index e3c35c123..c35647042 100644 --- a/ui/package.json +++ b/ui/package.json @@ -32,6 +32,7 @@ "pinia": "^2.1.6", "pinyin-pro": "^3.18.2", "vue": "^3.3.4", + "vue-clipboard3": "^2.0.0", "vue-router": "^4.2.4" }, "devDependencies": { diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index a2d3a2d35..e0852bb42 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -29,32 +29,6 @@ const getApplication: (param: pageRequest) => Promise> = (param) => ) } -/** - * 获得临时回话Id - * @param 参数 - * { - "model_id": "string", - "multiple_rounds_dialogue": true, - "dataset_id_list": [ - "string" - ] -} - */ -const postChatOpen: (data: ApplicationFormType) => Promise> = (data) => { - return post(`${prefix}/chat/open`, data) -} -/** - * 对话 - * @param 参数 - * chat_id: string - * { - "message": "string", - } - */ -const postChatMessage: (chat_id: string, message: string) => Promise = (chat_id, message) => { - return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message }) -} - /** * 创建应用 * @param 参数 @@ -156,16 +130,85 @@ const getAccessToken: (applicaiton_id: string, loading?: Ref) => Promis return get(`${prefix}/${applicaiton_id}/access_token`, undefined, loading) } +/** + * 应用认证 + * @param 参数 + { + "access_token": "string" +} + */ +const postAppAuthentication: (access_token: string, loading?: Ref) => Promise = ( + access_token, + loading +) => { + return post(`${prefix}/authentication`, { access_token }, undefined, loading) +} + +/** + * 对话获取应用相关信息 + * @param 参数 + { + "access_token": "string" +} + */ +const getProfile: (loading?: Ref) => Promise = (loading) => { + return get(`${prefix}/profile`, undefined, loading) +} + +/** + * 获得临时回话Id + * @param 参数 + * { + "model_id": "string", + "multiple_rounds_dialogue": true, + "dataset_id_list": [ + "string" + ] +} + */ +const postChatOpen: (data: ApplicationFormType) => Promise> = (data) => { + return post(`${prefix}/chat/open`, data) +} + +/** + * 正式回话Id + * @param 参数 + * { + "model_id": "string", + "multiple_rounds_dialogue": true, + "dataset_id_list": [ + "string" + ] +} + */ +const getChatOpen: (applicaiton_id: String) => Promise> = (applicaiton_id) => { + return get(`${prefix}/${applicaiton_id}/chat/open`) +} +/** + * 对话 + * @param 参数 + * chat_id: string + * { + "message": "string", + } + */ +const postChatMessage: (chat_id: string, message: string) => Promise = (chat_id, message) => { + return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message }) +} + export default { getAllAppilcation, getApplication, postApplication, putApplication, postChatOpen, + getChatOpen, postChatMessage, delApplication, getApplicationDetail, getApplicationDataset, getAPIKey, - getAccessToken + getAccessToken, + postAppAuthentication, + getProfile } diff --git a/ui/src/components/ai-dialog/index.vue b/ui/src/components/ai-dialog/index.vue index ffbff0e1e..27ffbdcaa 100644 --- a/ui/src/components/ai-dialog/index.vue +++ b/ui/src/components/ai-dialog/index.vue @@ -107,14 +107,21 @@