Skip to content

Commit

Permalink
fix: handle [DONE] message due to use 2023-01-01 API version
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsang4 committed Aug 23, 2023
1 parent 735d991 commit 21e28a3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 21e28a3

Please sign in to comment.