@@ -17,78 +17,76 @@ const createGenPrompt =
17
17
isTranslation = false ,
18
18
targetLanguage = '' ,
19
19
enableBidirectional = false ,
20
- includeLanguagePrefix = false
20
+ includeLanguagePrefix = false ,
21
21
} ) =>
22
- async ( selection ) => {
23
- const preferredLanguage = isTranslation
24
- ? targetLanguage
25
- : await getPreferredLanguage ( )
26
- let fullMessage = isTranslation
27
- ? `Translate the following into ${ preferredLanguage } and only show me the translated content`
28
- : message
29
- if ( enableBidirectional ) {
30
- fullMessage += `. If it is already in ${ preferredLanguage } , translate it into English and only show me the translated content`
31
- }
32
- const prefix = includeLanguagePrefix
33
- ? `Reply in ${ preferredLanguage } .`
34
- : ''
35
- return `${ prefix } ${ fullMessage } :\n'''\n${ selection } \n'''`
22
+ async ( selection ) => {
23
+ const preferredLanguage = isTranslation ? targetLanguage : await getPreferredLanguage ( )
24
+ let fullMessage = isTranslation
25
+ ? `Translate the following into ${ preferredLanguage } and only show me the translated content`
26
+ : message
27
+ if ( enableBidirectional ) {
28
+ fullMessage += `. If it is already in ${ preferredLanguage } , translate it into English and only show me the translated content`
36
29
}
30
+ const prefix = includeLanguagePrefix ? `Reply in ${ preferredLanguage } .` : ''
31
+ return `${ prefix } ${ fullMessage } :\n'''\n${ selection } \n'''`
32
+ }
37
33
38
34
export const config = {
39
35
explain : {
40
36
icon : < ChatText /> ,
41
37
label : 'Explain' ,
42
38
genPrompt : createGenPrompt ( {
43
39
message : 'Explain the following' ,
44
- includeLanguagePrefix : true
40
+ includeLanguagePrefix : true ,
45
41
} ) ,
46
42
} ,
47
43
translate : {
48
44
icon : < Translate /> ,
49
45
label : 'Translate' ,
50
46
genPrompt : createGenPrompt ( {
51
- isTranslation : true
47
+ isTranslation : true ,
48
+ targetLanguage : await getPreferredLanguage ( ) ,
52
49
} ) ,
53
50
} ,
54
51
translateToEn : {
55
52
icon : < Globe /> ,
56
53
label : 'Translate (To English)' ,
57
54
genPrompt : createGenPrompt ( {
58
55
isTranslation : true ,
59
- targetLanguage : 'English'
56
+ targetLanguage : 'English' ,
60
57
} ) ,
61
58
} ,
62
59
translateToZh : {
63
60
icon : < Globe /> ,
64
61
label : 'Translate (To Chinese)' ,
65
62
genPrompt : createGenPrompt ( {
66
63
isTranslation : true ,
67
- targetLanguage : 'Chinese'
64
+ targetLanguage : 'Chinese' ,
68
65
} ) ,
69
66
} ,
70
67
translateBidi : {
71
68
icon : < Globe /> ,
72
69
label : 'Translate (Bidirectional)' ,
73
70
genPrompt : createGenPrompt ( {
74
71
isTranslation : true ,
75
- enableBidirectional : true
72
+ targetLanguage : await getPreferredLanguage ( ) ,
73
+ enableBidirectional : true ,
76
74
} ) ,
77
75
} ,
78
76
summary : {
79
77
icon : < CardHeading /> ,
80
78
label : 'Summary' ,
81
79
genPrompt : createGenPrompt ( {
82
80
message : 'Summarize the following as concisely as possible' ,
83
- includeLanguagePrefix : true
81
+ includeLanguagePrefix : true ,
84
82
} ) ,
85
83
} ,
86
84
polish : {
87
85
icon : < Palette /> ,
88
86
label : 'Polish' ,
89
87
genPrompt : createGenPrompt ( {
90
88
message :
91
- 'Check the following content for possible diction and grammar problems, and polish it carefully'
89
+ 'Check the following content for possible diction and grammar problems, and polish it carefully' ,
92
90
} ) ,
93
91
} ,
94
92
sentiment : {
@@ -97,32 +95,30 @@ export const config = {
97
95
genPrompt : createGenPrompt ( {
98
96
message :
99
97
'Analyze the sentiments expressed in the following content and make a brief summary of the sentiments' ,
100
- includeLanguagePrefix : true
98
+ includeLanguagePrefix : true ,
101
99
} ) ,
102
100
} ,
103
101
divide : {
104
102
icon : < CardList /> ,
105
103
label : 'Divide Paragraphs' ,
106
104
genPrompt : createGenPrompt ( {
107
- message :
108
- 'Divide the following into paragraphs that are easy to read and understand'
105
+ message : 'Divide the following into paragraphs that are easy to read and understand' ,
109
106
} ) ,
110
107
} ,
111
108
code : {
112
109
icon : < Braces /> ,
113
110
label : 'Code Explain' ,
114
111
genPrompt : createGenPrompt ( {
115
112
message : 'Explain the following code' ,
116
- includeLanguagePrefix : true
113
+ includeLanguagePrefix : true ,
117
114
} ) ,
118
115
} ,
119
116
ask : {
120
117
icon : < QuestionCircle /> ,
121
118
label : 'Ask' ,
122
119
genPrompt : createGenPrompt ( {
123
- message :
124
- 'Analyze the following content and express your opinion, or give your answer' ,
125
- includeLanguagePrefix : true
120
+ message : 'Analyze the following content and express your opinion, or give your answer' ,
121
+ includeLanguagePrefix : true ,
126
122
} ) ,
127
123
} ,
128
124
}
0 commit comments