From 0755b54486b26d255b061681309fe1c558b931de Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Wed, 29 Mar 2023 22:49:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9B=B4=E6=8E=A5=E5=AF=B9=E8=AF=9D=E6=B2=A1?= =?UTF-8?q?=E4=BA=86=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=88=E4=B8=8D=E7=9F=A5?= =?UTF-8?q?=E9=81=93=E5=A5=BD=E4=BD=BF=E4=B8=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/SydneyAIClient.js | 56 ++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/utils/SydneyAIClient.js b/utils/SydneyAIClient.js index 133a849..a624f3b 100644 --- a/utils/SydneyAIClient.js +++ b/utils/SydneyAIClient.js @@ -674,33 +674,37 @@ export default class SydneyAIClient { } ws.send(`${messageJson}`) - const { - message: reply, - conversationExpiryTime - } = await messagePromise + try { + const { + message: reply, + conversationExpiryTime + } = await messagePromise + const replyMessage = { + id: crypto.randomUUID(), + parentMessageId: userMessage.id, + role: 'Bing', + message: reply.text, + details: reply + } + if (!Config.sydneyApologyIgnored || !apology) { + conversation.messages.push(userMessage) + conversation.messages.push(replyMessage) + } - const replyMessage = { - id: crypto.randomUUID(), - parentMessageId: userMessage.id, - role: 'Bing', - message: reply.text, - details: reply - } - if (!Config.sydneyApologyIgnored || !apology) { - conversation.messages.push(userMessage) - conversation.messages.push(replyMessage) - } - await this.conversationsCache.set(conversationKey, conversation) - return { - conversationSignature, - conversationId, - clientId, - invocationId: invocationId + 1, - messageId: replyMessage.id, - conversationExpiryTime, - response: reply.text, - details: reply, - apology: Config.sydneyApologyIgnored && apology + return { + conversationSignature, + conversationId, + clientId, + invocationId: invocationId + 1, + messageId: replyMessage.id, + conversationExpiryTime, + response: reply.text, + details: reply, + apology: Config.sydneyApologyIgnored && apology + } + } catch (err) { + await this.conversationsCache.set(conversationKey, conversation) + throw err } }