diff --git a/src/api/ai/chat/conversation/index.ts b/src/api/ai/chat/conversation/index.ts index e0ee8501..d394c6d2 100644 --- a/src/api/ai/chat/conversation/index.ts +++ b/src/api/ai/chat/conversation/index.ts @@ -13,6 +13,7 @@ export interface ChatConversationVO { maxTokens: number // 单条回复的最大 Token 数量 maxContexts: number // 上下文的最大 Message 数量 // 额外字段 + modelName?: string // 模型名字 roleAvatar?: string // 角色头像 modelMaxTokens?: string // 模型的单条回复的最大 Token 数量 modelMaxContexts?: string // 模型的上下文的最大 Message 数量 @@ -21,19 +22,25 @@ export interface ChatConversationVO { // AI 聊天会话 API export const ChatConversationApi = { // 获得【我的】聊天会话 - getChatConversationMy: async (id: string) => { + getChatConversationMy: async (id: number) => { return await request.get({ url: `/ai/chat/conversation/get-my?id=${id}` }) }, - // 更新【我的】聊天会话 - updateChatConversationMy: async (data: ChatConversationVO) => { - return await request.put({ url: `/ai/chat/conversation/update-my`, data }) - }, // 新增【我的】聊天会话 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: number) => { + return await request.delete({ url: `/ai/chat/conversation/delete-my?id=${id}` }) + }, + // 获得【我的】聊天会话列表 getChatConversationMyList: async () => { return await request.get({ url: `/ai/chat/conversation/my-list` }) diff --git a/src/api/ai/chat/message/index.ts b/src/api/ai/chat/message/index.ts index 0138651b..b4e80816 100644 --- a/src/api/ai/chat/message/index.ts +++ b/src/api/ai/chat/message/index.ts @@ -31,19 +31,16 @@ export const ChatMessageApi = { }) }, - // 发送 add 消息 - add: async (data: ChatMessageSendVO) => { - return await request.post({ url: `/ai/chat/message/add`, data }) - }, - - // 发送 send 消息 - send: async (data: ChatMessageSendVO) => { - return await request.post({ url: `/ai/chat/message/send`, data }) - }, - // 发送 send stream 消息 // TODO axios 可以么? https://apifox.com/apiskills/how-to-create-axios-stream/ - sendStream: async (id: string, ctrl, onMessage, onError, onClose) => { + sendStream: async ( + conversationId: number, + content: string, + ctrl, + onMessage, + onError, + onClose + ) => { const token = getAccessToken() return fetchEventSource(`${config.base_url}/ai/chat/message/send-stream`, { method: 'post', @@ -53,7 +50,8 @@ export const ChatMessageApi = { }, openWhenHidden: true, body: JSON.stringify({ - id: id + conversationId, + content }), onmessage: onMessage, onerror: onError, diff --git a/src/views/ai/chat/components/ChatConversationUpdateForm.vue b/src/views/ai/chat/components/ChatConversationUpdateForm.vue index 0a754dd8..fe08ffb2 100644 --- a/src/views/ai/chat/components/ChatConversationUpdateForm.vue +++ b/src/views/ai/chat/components/ChatConversationUpdateForm.vue @@ -4,23 +4,46 @@ ref="formRef" :model="formData" :rules="formRules" - label-width="100px" + label-width="130px" v-loading="formLoading" > - - + + - + + + - - + + - - + + - - + +