From 5fb86a8f15acca5a6cdbb0044a0922bf1ede427a Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Fri, 24 Nov 2023 19:02:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/application.ts | 69 ++++++++- ui/src/api/dataset.ts | 6 +- ui/src/api/type/application.ts | 8 +- ui/src/assets/icon_send.svg | 4 + ui/src/assets/icon_send_colorful.svg | 14 ++ ui/src/components/ai-dialog/index.vue | 63 ++++++++- ui/src/components/back-button/index.vue | 10 +- ui/src/components/icons/index.ts | 49 +++---- ui/src/layout/components/app-main/index.vue | 2 +- .../components/sidebar/AppBreadcrumb.vue | 131 ++++++++++++++++++ ui/src/layout/components/sidebar/index.vue | 12 ++ ui/src/router/modules/application.ts | 8 +- ui/src/router/modules/dataset.ts | 8 +- ui/src/stores/index.ts | 8 +- ui/src/stores/modules/application.ts | 23 +++ ui/src/stores/modules/common.ts | 17 +++ ui/src/stores/modules/dataset.ts | 13 ++ ui/src/styles/app.scss | 8 ++ ui/src/styles/element-plus.scss | 4 + ui/src/views/application/CreateAndSetting.vue | 59 ++++++-- .../components/AddDatasetDialog.vue | 32 +++-- ui/src/views/document/DatasetSetting.vue | 6 +- ui/src/views/document/index.vue | 14 +- .../paragraph/component/ParagraphDialog.vue | 6 +- .../paragraph/component/ProblemComponent.vue | 8 +- ui/src/views/paragraph/index.vue | 10 +- 26 files changed, 497 insertions(+), 95 deletions(-) create mode 100644 ui/src/assets/icon_send.svg create mode 100644 ui/src/assets/icon_send_colorful.svg create mode 100644 ui/src/layout/components/sidebar/AppBreadcrumb.vue create mode 100644 ui/src/stores/modules/application.ts create mode 100644 ui/src/stores/modules/common.ts diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index b1c103fa3..289cf20e2 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -1,8 +1,17 @@ import { Result } from '@/request/Result' import { get, post, del, put } from '@/request/index' import type { pageRequest } from '@/api/type/common' +import type { ApplicationFormType } from '@/api/type/application' const prefix = '/application' +/** + * 获取全部应用 + * @param 参数 + */ +const getAllAppilcation: () => Promise> = () => { + return get(`${prefix}`) +} + /** * 获取分页应用 * @param 参数 { @@ -17,6 +26,62 @@ const getApplication: (param: pageRequest) => Promise> = (param) => param.name && { name: param.name } ) } -export default { - getApplication + +/** + * 创建数据集 + * @param 参数 + * { + "name": "string", + "desc": "string", + "model_id": "string", + "multiple_rounds_dialogue": true, + "prologue": "string", + "example": [ + "string" + ], + "dataset_id_list": [ + "string" + ] +} + */ +const postApplication: (data: ApplicationFormType) => Promise> = (data) => { + return post(`${prefix}`, data) +} + +// 临时对话open +/** + * 创建数据集 + * @param 参数 + * { + "model_id": "string", + "multiple_rounds_dialogue": true, + "dataset_id_list": [ + "string" + ] +} + */ +const postChatOpen: (data: ApplicationFormType) => Promise> = (data) => { + return post(`${prefix}/chat/open`, data) +} +// 临时对话open +/** + * 创建数据集 + * @param 参数 + * chat_id: string + * { + "message": "string", + } + */ +const postChatMessage: (chat_id: string, message: string) => Promise> = ( + chat_id, + message +) => { + return post(`${prefix}/chat_message/${chat_id}`, { message }) +} +export default { + getAllAppilcation, + getApplication, + postApplication, + postChatOpen, + postChatMessage } diff --git a/ui/src/api/dataset.ts b/ui/src/api/dataset.ts index 106956e74..9247e4e4a 100644 --- a/ui/src/api/dataset.ts +++ b/ui/src/api/dataset.ts @@ -21,10 +21,10 @@ const getDateset: (param: pageRequest) => Promise> = (param) => { /** * 获取全部数据集 - * @param 参数 name + * @param 参数 */ -const getAllDateset: (param?: string) => Promise> = (param) => { - return get(`${prefix}`, param && { name: param }) +const getAllDateset: () => Promise> = () => { + return get(`${prefix}`) } /** diff --git a/ui/src/api/type/application.ts b/ui/src/api/type/application.ts index ff4f7b8e0..69926c7a5 100644 --- a/ui/src/api/type/application.ts +++ b/ui/src/api/type/application.ts @@ -1,10 +1,10 @@ interface ApplicationFormType { - name: string - desc: string + name?: string + desc?: string model_id: string multiple_rounds_dialogue: boolean - prologue: string - example: string[] + prologue?: string + example?: string[] dataset_id_list: string[] } export type { ApplicationFormType } diff --git a/ui/src/assets/icon_send.svg b/ui/src/assets/icon_send.svg new file mode 100644 index 000000000..79ff6425d --- /dev/null +++ b/ui/src/assets/icon_send.svg @@ -0,0 +1,4 @@ + + + + diff --git a/ui/src/assets/icon_send_colorful.svg b/ui/src/assets/icon_send_colorful.svg new file mode 100644 index 000000000..b6a1dacb6 --- /dev/null +++ b/ui/src/assets/icon_send_colorful.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/ui/src/components/ai-dialog/index.vue b/ui/src/components/ai-dialog/index.vue index ead74679a..82ac6285e 100644 --- a/ui/src/components/ai-dialog/index.vue +++ b/ui/src/components/ai-dialog/index.vue @@ -23,7 +23,11 @@

您可以尝试输入以下问题:

diff --git a/ui/src/components/icons/index.ts b/ui/src/components/icons/index.ts index 69acdd534..7e102a3d8 100644 --- a/ui/src/components/icons/index.ts +++ b/ui/src/components/icons/index.ts @@ -174,30 +174,31 @@ export const iconMap: any = { ]) } }, - 'app-send': { - iconReader: () => { - return h('i', [ - h( - 'svg', - { - viewBox: '0 0 24 24', - version: '1.1', - xmlns: 'http://www.w3.org/2000/svg' - }, - [ - h('path', { - d: 'M20.1716 1.68834C20.6753 1.53273 21.0458 2.16193 20.6652 2.52691L12.2658 10.5836C11.0058 11.7921 9.32754 12.4668 7.5817 12.4668C5.68044 12.4668 3.8669 11.667 2.58487 10.263L1.45879 9.02985C1.33225 8.90313 1.24137 8.74527 1.19534 8.5722C1.14931 8.39913 1.14974 8.21698 1.19661 8.04413C1.24347 7.87129 1.3351 7.71386 1.46225 7.58775C1.5894 7.46164 1.74757 7.3713 1.92079 7.32585L20.1716 1.68834Z', - fill: 'currentColor' - }), - h('path', { - d: 'M12 16.1851C12 14.2766 12.7377 12.4419 14.0588 11.0646L21.4664 3.34177C21.8268 2.96601 22.4499 3.32266 22.3084 3.82374L17.143 22.1182C17.0971 22.291 17.0064 22.4487 16.8801 22.5754C16.7538 22.7021 16.5964 22.7932 16.4237 22.8397C16.251 22.8862 16.0691 22.8864 15.8964 22.8402C15.7236 22.794 15.566 22.7031 15.4395 22.5767L14.4439 21.6791C12.8881 20.2764 12 18.2799 12 16.1851Z', - fill: 'currentColor' - }) - ] - ) - ]) - } - }, + // 'app-send': { + // iconReader: () => { + // return h('i', [ + // h( + // 'svg', + // { + // viewBox: '0 0 24 24', + // version: '1.1', + // xmlns: 'http://www.w3.org/2000/svg' + // }, + // [ + // h('path', { + // d: 'M20.1716 1.68834C20.6753 1.53273 21.0458 2.16193 20.6652 2.52691L12.2658 10.5836C11.0058 11.7921 9.32754 12.4668 7.5817 12.4668C5.68044 12.4668 3.8669 11.667 2.58487 10.263L1.45879 9.02985C1.33225 8.90313 1.24137 8.74527 1.19534 8.5722C1.14931 8.39913 1.14974 8.21698 1.19661 8.04413C1.24347 7.87129 1.3351 7.71386 1.46225 7.58775C1.5894 7.46164 1.74757 7.3713 1.92079 7.32585L20.1716 1.68834Z', + // fill: 'currentColor' + // }), + // h('path', { + // d: 'M12 16.1851C12 14.2766 12.7377 12.4419 14.0588 11.0646L21.4664 3.34177C21.8268 2.96601 22.4499 3.32266 22.3084 3.82374L17.143 22.1182C17.0971 22.291 17.0064 22.4487 16.8801 22.5754C16.7538 22.7021 16.5964 22.7932 16.4237 22.8397C16.251 22.8862 16.0691 22.8864 15.8964 22.8402C15.7236 22.794 15.566 22.7031 15.4395 22.5767L14.4439 21.6791C12.8881 20.2764 12 18.2799 12 16.1851Z', + // fill: 'currentColor' + // }) + // ] + // ) + // ]) + // } + // }, + 'app-view': { iconReader: () => { return h('i', [ diff --git a/ui/src/layout/components/app-main/index.vue b/ui/src/layout/components/app-main/index.vue index c37ef497c..d9a3fabe5 100644 --- a/ui/src/layout/components/app-main/index.vue +++ b/ui/src/layout/components/app-main/index.vue @@ -2,7 +2,7 @@ - + diff --git a/ui/src/layout/components/sidebar/AppBreadcrumb.vue b/ui/src/layout/components/sidebar/AppBreadcrumb.vue new file mode 100644 index 000000000..e6f965041 --- /dev/null +++ b/ui/src/layout/components/sidebar/AppBreadcrumb.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/ui/src/layout/components/sidebar/index.vue b/ui/src/layout/components/sidebar/index.vue index ab402452e..e176daa4d 100644 --- a/ui/src/layout/components/sidebar/index.vue +++ b/ui/src/layout/components/sidebar/index.vue @@ -1,5 +1,8 @@