diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 5fb4339..2a82185 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -413,7 +413,7 @@ async function sendMessage( }) .catch(async (err) => { // if 409 - if (err.response.status === 409) { + if (err.response?.status === 409) { const streamId = err.response.data.data?.stream_id; if (streamId) { @@ -481,6 +481,14 @@ function streamChat(streamId: String, redirect = false) { const url = getApi().conf.basePath + "/api/v1/stream/" + streamId; const evtSource = new EventSource(url); + // 如果 error + evtSource.onerror = (e) => { + dialog.error({ + title: "推理失败", + content: "目前无法完成推理,请稍后再试。", + positiveText: "好", + }); + } let messageAdded = false; diff --git a/src/plugins/httpInterceptors.ts b/src/plugins/httpInterceptors.ts index 7959fea..ed7f244 100644 --- a/src/plugins/httpInterceptors.ts +++ b/src/plugins/httpInterceptors.ts @@ -101,13 +101,6 @@ const response = { return h(error500); }, }); - } else { - if (data.length !== 0) { - dialog.error({ - title: "错误", - content: data, - }); - } } return Promise.reject(error);