feat:【antd】【ai】chat “返回异常时空消息删除”的迁移
This commit is contained in:
@@ -8,6 +8,7 @@ import { requestClient } from '#/api/request';
|
|||||||
|
|
||||||
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
|
|
||||||
export namespace AiChatMessageApi {
|
export namespace AiChatMessageApi {
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
id: number; // 编号
|
id: number; // 编号
|
||||||
@@ -26,10 +27,21 @@ export namespace AiChatMessageApi {
|
|||||||
documentName: string; // 文档名称
|
documentName: string; // 文档名称
|
||||||
id: number; // 段落编号
|
id: number; // 段落编号
|
||||||
}[];
|
}[];
|
||||||
|
webSearchPages?: WebSearchPage[]; // 联网搜索结果
|
||||||
createTime: Date; // 创建时间
|
createTime: Date; // 创建时间
|
||||||
roleAvatar: string; // 角色头像
|
roleAvatar: string; // 角色头像
|
||||||
userAvatar: string; // 用户头像
|
userAvatar: string; // 用户头像
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 联网搜索页面接口 */
|
||||||
|
export interface WebSearchPage {
|
||||||
|
name: string; // 网站名称
|
||||||
|
icon: string; // 网站图标 URL
|
||||||
|
title: string; // 页面标题
|
||||||
|
url: string; // 页面 URL
|
||||||
|
snippet: string; // 简短描述
|
||||||
|
summary: string; // 内容摘要
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 消息列表
|
// 消息列表
|
||||||
@@ -47,6 +59,7 @@ export function sendChatMessageStream(
|
|||||||
content: string,
|
content: string,
|
||||||
ctrl: any,
|
ctrl: any,
|
||||||
enableContext: boolean,
|
enableContext: boolean,
|
||||||
|
enableWebSearch: boolean,
|
||||||
onMessage: any,
|
onMessage: any,
|
||||||
onError: any,
|
onError: any,
|
||||||
onClose: any,
|
onClose: any,
|
||||||
@@ -63,6 +76,7 @@ export function sendChatMessageStream(
|
|||||||
conversationId,
|
conversationId,
|
||||||
content,
|
content,
|
||||||
useContext: enableContext,
|
useContext: enableContext,
|
||||||
|
useSearch: enableWebSearch,
|
||||||
}),
|
}),
|
||||||
onmessage: onMessage,
|
onmessage: onMessage,
|
||||||
onerror: onError,
|
onerror: onError,
|
||||||
|
|||||||
@@ -359,6 +359,10 @@ async function doSendMessageStream(userMessage: AiChatMessageApi.ChatMessage) {
|
|||||||
const { code, data, msg } = JSON.parse(res.data);
|
const { code, data, msg } = JSON.parse(res.data);
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
await alert(`对话异常! ${msg}`);
|
await alert(`对话异常! ${msg}`);
|
||||||
|
// 如果未接收到消息,则进行删除
|
||||||
|
if (receiveMessageFullText.value === '') {
|
||||||
|
activeMessageList.value.pop();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,7 +386,8 @@ async function doSendMessageStream(userMessage: AiChatMessageApi.ChatMessage) {
|
|||||||
await scrollToBottom();
|
await scrollToBottom();
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
alert(`对话异常! ${error}`);
|
// 异常提示,并停止流
|
||||||
|
alert(`对话异常!`);
|
||||||
stopStream();
|
stopStream();
|
||||||
// 需要抛出异常,禁止重试
|
// 需要抛出异常,禁止重试
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user