From 449ae6c8ef68b3da6abdba63804f8fb8e0af0e89 Mon Sep 17 00:00:00 2001 From: Jiemin Wu <604096529@qq.com> Date: Fri, 3 Mar 2023 22:57:58 +0800 Subject: [PATCH] fix: no translation for some sentences (#16) --- src/main.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.js b/src/main.js index 780f691..1ce1e38 100644 --- a/src/main.js +++ b/src/main.js @@ -49,7 +49,7 @@ function translate(query, completion) { if (isChatGPTModel) { body.messages = [ { role: "system", content: prompt }, - { role: "user", content: query.text }, + { role: "user", content: `"${query.text}"` }, ]; } else { body.prompt = `${prompt}:\n\n"${query.text}" =>`; @@ -95,14 +95,14 @@ function translate(query, completion) { } else { targetTxt = choices[0].text.trim(); } - if (!isChatGPTModel) { - if (targetTxt.startsWith('"')) { - targetTxt = targetTxt.slice(1); - } - if (targetTxt.endsWith('"')) { - targetTxt = targetTxt.slice(0, -1); - } + + if (targetTxt.startsWith('"')) { + targetTxt = targetTxt.slice(1); } + if (targetTxt.endsWith('"')) { + targetTxt = targetTxt.slice(0, -1); + } + completion({ result: { from: query.detectFrom,