From 21e28a34587c98f31d2572429b9c12160d188d96 Mon Sep 17 00:00:00 2001 From: jtsang4 Date: Thu, 24 Aug 2023 04:08:55 +0800 Subject: [PATCH] fix: handle [DONE] message due to use 2023-01-01 API version --- src/main.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 38dea4f..5fcf918 100644 --- a/src/main.js +++ b/src/main.js @@ -208,9 +208,11 @@ function translate(query) { buffer += splitedText[0]; const match = buffer.startsWith('data:') ? buffer.slice(5) : buffer; const textFromResponse = match.trim(); - const responseObj = JSON.parse(textFromResponse); - targetText = handleResponse(query, targetText, responseObj); - buffer = ''; + if (textFromResponse !== '[DONE]') { + const responseObj = JSON.parse(textFromResponse); + targetText = handleResponse(query, targetText, responseObj); + buffer = ''; + } } }, handler: (result) => {