Skip to content

Commit 449ae6c

Browse files
authored
fix: no translation for some sentences (#16)
1 parent 0fcd520 commit 449ae6c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function translate(query, completion) {
4949
if (isChatGPTModel) {
5050
body.messages = [
5151
{ role: "system", content: prompt },
52-
{ role: "user", content: query.text },
52+
{ role: "user", content: `"${query.text}"` },
5353
];
5454
} else {
5555
body.prompt = `${prompt}:\n\n"${query.text}" =>`;
@@ -95,14 +95,14 @@ function translate(query, completion) {
9595
} else {
9696
targetTxt = choices[0].text.trim();
9797
}
98-
if (!isChatGPTModel) {
99-
if (targetTxt.startsWith('"')) {
100-
targetTxt = targetTxt.slice(1);
101-
}
102-
if (targetTxt.endsWith('"')) {
103-
targetTxt = targetTxt.slice(0, -1);
104-
}
98+
99+
if (targetTxt.startsWith('"')) {
100+
targetTxt = targetTxt.slice(1);
105101
}
102+
if (targetTxt.endsWith('"')) {
103+
targetTxt = targetTxt.slice(0, -1);
104+
}
105+
106106
completion({
107107
result: {
108108
from: query.detectFrom,

0 commit comments

Comments
 (0)