Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -147,14 +147,15 @@ def translate_to_english(llm, user_query):
|
|
| 147 |
You are an AI assistant that translates a text to English. \
|
| 148 |
Do not generate any irrelavant text, only return the translation."""
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
)
|
| 155 |
-
|
|
|
|
| 156 |
|
| 157 |
-
output = llm.invoke(
|
| 158 |
pred = output.content
|
| 159 |
|
| 160 |
return pred
|
|
@@ -165,14 +166,15 @@ def translate(llm, user_query, to_translate):
|
|
| 165 |
Do not generate any irrelavant text, only return the translation. \
|
| 166 |
If the user query is in English, then don't do anything just return the original text, no translation is required there.""".format(user_query)
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
)
|
| 173 |
-
|
|
|
|
| 174 |
|
| 175 |
-
output = llm.invoke(
|
| 176 |
pred = output.content
|
| 177 |
|
| 178 |
return pred
|
|
|
|
| 147 |
You are an AI assistant that translates a text to English. \
|
| 148 |
Do not generate any irrelavant text, only return the translation."""
|
| 149 |
|
| 150 |
+
messages = [
|
| 151 |
+
(
|
| 152 |
+
"system",
|
| 153 |
+
sys_prompt,
|
| 154 |
+
),
|
| 155 |
+
("human", user_query),
|
| 156 |
+
]
|
| 157 |
|
| 158 |
+
output = llm.invoke(messages)
|
| 159 |
pred = output.content
|
| 160 |
|
| 161 |
return pred
|
|
|
|
| 166 |
Do not generate any irrelavant text, only return the translation. \
|
| 167 |
If the user query is in English, then don't do anything just return the original text, no translation is required there.""".format(user_query)
|
| 168 |
|
| 169 |
+
messages = [
|
| 170 |
+
(
|
| 171 |
+
"system",
|
| 172 |
+
sys_prompt,
|
| 173 |
+
),
|
| 174 |
+
("human", to_translate),
|
| 175 |
+
]
|
| 176 |
|
| 177 |
+
output = llm.invoke(messages)
|
| 178 |
pred = output.content
|
| 179 |
|
| 180 |
return pred
|