From 92cbf3198b9842097d7a5df13e875ed00d0fcfb0 Mon Sep 17 00:00:00 2001 From: somanchiu <8416023+somanchiu@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:26:29 +0800 Subject: [PATCH 1/2] Fix #527, Also, specific message types can now be handled in onProgress. --- src/BingAIClient.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/BingAIClient.js b/src/BingAIClient.js index b2212d57..5ee510d7 100644 --- a/src/BingAIClient.js +++ b/src/BingAIClient.js @@ -458,15 +458,16 @@ export default class BingAIClient { return; } // get the difference between the current text and the previous text - const difference = updatedText.substring(replySoFar.length); - onProgress(difference); + const difference = messages[0].messageType ? updatedText : updatedText.substring(replySoFar.length); + onProgress(difference, messages[0].messageType); if (updatedText.trim().endsWith(stopToken)) { stopTokenFound = true; // remove stop token from updated text replySoFar = updatedText.replace(stopToken, '').trim(); return; } - replySoFar = updatedText; + if(!messages[0].messageType) + replySoFar = updatedText; return; } case 2: { From 6aac1558d34a0225621d52071154cd7b307d26c4 Mon Sep 17 00:00:00 2001 From: somanchiu <8416023+somanchiu@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:39:53 +0800 Subject: [PATCH 2/2] Fix build checks --- src/BingAIClient.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BingAIClient.js b/src/BingAIClient.js index 5ee510d7..18871e45 100644 --- a/src/BingAIClient.js +++ b/src/BingAIClient.js @@ -466,8 +466,9 @@ export default class BingAIClient { replySoFar = updatedText.replace(stopToken, '').trim(); return; } - if(!messages[0].messageType) + if (!messages[0].messageType) { replySoFar = updatedText; + } return; } case 2: {