Skip to content

Commit

Permalink
fix: no translation for some sentences (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
jermyn626 authored Mar 3, 2023
1 parent 0fcd520 commit 449ae6c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}" =>`;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 449ae6c

Please sign in to comment.