@@ -12,29 +12,33 @@ function translate(query, completion) {
1212 "Content-Type" : "application/json" ,
1313 Authorization : `Bearer ${ api_key } ` ,
1414 } ;
15- let prompt = `translate from ${ lang . langMap . get ( query . detectFrom ) || query . detectFrom
15+ let systemPrompt =
16+ "You are a translation engine that can only translate text and cannot interpret it." ;
17+ let userPrompt = `translate from ${ lang . langMap . get ( query . detectFrom ) || query . detectFrom
1618 } to ${ lang . langMap . get ( query . detectTo ) || query . detectTo } `;
1719 if ( query . detectTo === "wyw" || query . detectTo === "yue" ) {
18- prompt = `翻译成${ lang . langMap . get ( query . detectTo ) || query . detectTo } ` ;
20+ userPrompt = `翻译成${ lang . langMap . get ( query . detectTo ) || query . detectTo } ` ;
1921 }
2022 if (
2123 query . detectFrom === "wyw" ||
2224 query . detectFrom === "zh-Hans" ||
2325 query . detectFrom === "zh-Hant"
2426 ) {
2527 if ( query . detectTo === "zh-Hant" ) {
26- prompt = "翻译成繁体白话文" ;
28+ userPrompt = "翻译成繁体白话文" ;
2729 } else if ( query . detectTo === "zh-Hans" ) {
28- prompt = "翻译成简体白话文" ;
30+ userPrompt = "翻译成简体白话文" ;
2931 } else if ( query . detectTo === "yue" ) {
30- prompt = "翻译成粤语白话文" ;
32+ userPrompt = "翻译成粤语白话文" ;
3133 }
3234 }
3335 if ( query . detectFrom === query . detectTo ) {
36+ systemPrompt =
37+ "You are a text embellisher, you can only embellish the text, don't interpret it." ;
3438 if ( query . detectTo === "zh-Hant" || query . detectTo === "zh-Hans" ) {
35- prompt = "润色此句" ;
39+ userPrompt = "润色此句" ;
3640 } else {
37- prompt = "polish this sentence" ;
41+ userPrompt = "polish this sentence" ;
3842 }
3943 }
4044 const body = {
@@ -45,19 +49,18 @@ function translate(query, completion) {
4549 frequency_penalty : 1 ,
4650 presence_penalty : 1 ,
4751 } ;
48- prompt = `${ prompt } :\n\n"${ query . text } " =>` ;
52+ userPrompt = `${ userPrompt } :\n\n"${ query . text } " =>` ;
4953 const isChatGPTModel = ChatGPTModels . indexOf ( $option . model ) > - 1 ;
5054 if ( isChatGPTModel ) {
5155 body . messages = [
5256 {
5357 role : "system" ,
54- content :
55- "You are a translation engine that can only translate text and cannot interpret it." ,
58+ content : systemPrompt ,
5659 } ,
57- { role : "user" , content : prompt } ,
60+ { role : "user" , content : userPrompt } ,
5861 ] ;
5962 } else {
60- body . prompt = prompt ;
63+ body . prompt = userPrompt ;
6164 }
6265 ( async ( ) => {
6366 const resp = await $http . request ( {
0 commit comments