From c560a440e97add9809bd3dabb9013cf70c27b59b Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Tue, 21 Mar 2023 13:24:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Daplogy=E6=89=93?= =?UTF-8?q?=E4=B9=B1=E9=A1=BA=E5=BA=8F=E4=B8=A2=E5=A4=B1=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/chat.js | 2 +- utils/SydneyAIClient.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/chat.js b/apps/chat.js index a93c517..7252fef 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -1012,7 +1012,7 @@ export class chatgpt extends plugin { clientId: response.clientId, invocationId: response.invocationId, conversationSignature: response.conversationSignature, - parentMessageId: response.messageId + parentMessageId: response.apology ? conversation.parentMessageId : response.messageId } } } diff --git a/utils/SydneyAIClient.js b/utils/SydneyAIClient.js index 17f4db3..f836c37 100644 --- a/utils/SydneyAIClient.js +++ b/utils/SydneyAIClient.js @@ -444,7 +444,7 @@ export default class SydneyAIClient { reject('Request aborted') } }) - let apology = false + // let apology = false ws.on('message', (data) => { const objects = data.toString().split('') const events = objects.map((object) => { @@ -507,7 +507,7 @@ export default class SydneyAIClient { const difference = updatedText.substring(replySoFar.length) onProgress(difference) if (updatedText.trim().endsWith(stopToken)) { - apology = true + // apology = true // remove stop token from updated text replySoFar = updatedText.replace(stopToken, '').trim() return @@ -618,9 +618,8 @@ export default class SydneyAIClient { if (!apology) { conversation.messages.push(userMessage) conversation.messages.push(replyMessage) - - await this.conversationsCache.set(conversationKey, conversation) } + await this.conversationsCache.set(conversationKey, conversation) return { conversationSignature, conversationId,