-
Notifications
You must be signed in to change notification settings - Fork 5
/
utils.py
170 lines (150 loc) · 5.87 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
def get_chatgpt_prompt_to_arabic(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Modern Standard Arabic translator. Please provide the translation of the provided English text into Modern Standard Arabic, ensuring to respect the right-to-left writing system of Arabic. Make sure all Nunnation is appropriately reflected in the translated text along with correct punctuation. Only output the Modern Standard Arabic translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to arabic: <{english_str}>. "
"Only output the Arabic translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_chinese(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Chinese translator. Please provide the Chinese translation of the provided English text. Only output the Chinese translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to Chinese: <{english_str}>. "
"Only output the Chinese translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_spanish(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Spanish translator. Please provide the Spanish translation of the provided English text. Only output the Spanish translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to Spanish: <{english_str}>. "
"Only output the Spanish translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_hindi(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Hindi translator. Please provide the Hindi translation of the provided English text. Only output the Hindi translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to Hindi: <{english_str}>. "
"Only output the Hindi translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_french(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to French translator. Please provide the French translation of the provided English text. Only output the French translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to French: <{english_str}>. "
"Only output the French translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_german(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to German translator. Please provide the German translation of the provided English text. Only output the German translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to German: <{english_str}>. "
"Only output the German translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_russian(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Russian translator. Please provide the Russian translation of the provided English text. Only output the Russian translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to Russian: <{english_str}>. "
"Only output the Russian translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_urdu(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Urdu translator. Please provide the Urdu translation of the provided English text. Only output the Urdu translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to Urdu: <{english_str}>. "
"Only output the Urdu translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_bengali(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Bengali translator. Please provide the Bengali translation of the provided English text. Only output the Bengali translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to Bengali: <{english_str}>. "
"Only output the Bengali translation. Do not output anything else."
}
]
return messages
def get_chatgpt_prompt_japanese(english_str):
messages = [
{
"role": "system",
"content":
"You are an English to Japanese translator. Please provide the Japanese translation of the provided English text. Only output the Japanese translation."
},
{
"role": "user",
"content":
f"Translate the English phrase/word enclosed in <> to Japanese: <{english_str}>. "
"Only output the Japanese translation. Do not output anything else."
}
]
return messages