From d172d3db738c976fde48312edb75de2a89263052 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 25 May 2024 00:08:40 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91AI=EF=BC=9A?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E7=AE=A1=E7=90=86=2050%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/chat/conversation/index.ts | 21 ++-- src/api/ai/chat/message/index.ts | 4 +- src/views/ai/chat/Conversation.vue | 8 +- src/views/ai/chat/index.vue | 7 +- src/views/ai/chat/manager/index.vue | 174 ++++++++++++++++++++++++++ 5 files changed, 196 insertions(+), 18 deletions(-) create mode 100644 src/views/ai/chat/manager/index.vue diff --git a/src/api/ai/chat/conversation/index.ts b/src/api/ai/chat/conversation/index.ts index 0834643d..07643255 100644 --- a/src/api/ai/chat/conversation/index.ts +++ b/src/api/ai/chat/conversation/index.ts @@ -1,10 +1,10 @@ import request from '@/config/axios' -// AI 聊天会话 VO +// AI 聊天对话 VO export interface ChatConversationVO { id: string // ID 编号 userId: number // 用户编号 - title: string // 会话标题 + title: string // 对话标题 pinned: boolean // 是否置顶 roleId: number // 角色编号 modelId: number // 模型编号 @@ -20,24 +20,24 @@ export interface ChatConversationVO { modelMaxContexts?: string // 模型的上下文的最大 Message 数量 } -// AI 聊天会话 API +// AI 聊天对话 API export const ChatConversationApi = { - // 获得【我的】聊天会话 + // 获得【我的】聊天对话 getChatConversationMy: async (id: string) => { return await request.get({ url: `/ai/chat/conversation/get-my?id=${id}` }) }, - // 新增【我的】聊天会话 + // 新增【我的】聊天对话 createChatConversationMy: async (data?: ChatConversationVO) => { return await request.post({ url: `/ai/chat/conversation/create-my`, data }) }, - // 更新【我的】聊天会话 + // 更新【我的】聊天对话 updateChatConversationMy: async (data: ChatConversationVO) => { return await request.put({ url: `/ai/chat/conversation/update-my`, data }) }, - // 删除【我的】聊天会话 + // 删除【我的】聊天对话 deleteChatConversationMy: async (id: string) => { return await request.delete({ url: `/ai/chat/conversation/delete-my?id=${id}` }) }, @@ -47,8 +47,13 @@ export const ChatConversationApi = { return await request.delete({ url: `/ai/chat/conversation/delete-my-all-except-pinned` }) }, - // 获得【我的】聊天会话列表 + // 获得【我的】聊天对话列表 getChatConversationMyList: async () => { return await request.get({ url: `/ai/chat/conversation/my-list` }) + }, + + // 获得对话分页 + getChatConversationPage: async (params: any) => { + return await request.get({ url: `/ai/chat/conversation/page`, params }) } } diff --git a/src/api/ai/chat/message/index.ts b/src/api/ai/chat/message/index.ts index 0547ab1b..7b46f9c2 100644 --- a/src/api/ai/chat/message/index.ts +++ b/src/api/ai/chat/message/index.ts @@ -6,7 +6,7 @@ import { config } from '@/config/axios/config' // 聊天VO export interface ChatMessageVO { id: number // 编号 - conversationId: number // 会话编号 + conversationId: number // 对话编号 type: string // 消息类型 userId: string // 用户编号 roleId: string // 角色编号 @@ -20,7 +20,7 @@ export interface ChatMessageVO { } export interface ChatMessageSendVO { - conversationId: string // 会话编号 + conversationId: string // 对话编号 content: number // 聊天内容 } diff --git a/src/views/ai/chat/Conversation.vue b/src/views/ai/chat/Conversation.vue index 3c0af731..3a141fd5 100644 --- a/src/views/ai/chat/Conversation.vue +++ b/src/views/ai/chat/Conversation.vue @@ -59,7 +59,7 @@ - + @@ -296,15 +296,15 @@ const updateConversationTitle = async (conversation: ChatConversationVO) => { } /** - * 删除聊天会话 + * 删除聊天对话 */ const deleteChatConversation = async (conversation: ChatConversationVO) => { try { // 删除的二次确认 - await message.delConfirm(`是否确认删除会话 - ${conversation.title}?`) + await message.delConfirm(`是否确认删除对话 - ${conversation.title}?`) // 发起删除 await ChatConversationApi.deleteChatConversationMy(conversation.id) - message.success('会话已删除') + message.success('对话已删除') // 刷新列表 await getChatConversationList() // 回调 diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue index d4ca76a8..83231b57 100644 --- a/src/views/ai/chat/index.vue +++ b/src/views/ai/chat/index.vue @@ -1,6 +1,6 @@