Update app.py
Browse files
app.py
CHANGED
|
@@ -210,7 +210,12 @@ class Translators:
|
|
| 210 |
return translation[0]['translation_text'], message
|
| 211 |
except Exception as error:
|
| 212 |
return f"Error translating with model: {self.model_name}! Try other available language combination or model.", error
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
def salamandraTA(self):
|
| 215 |
# from datetime import datetime
|
| 216 |
text = f"Translate the following text from {self.sl} into {self.tl}.\n{self.sl}: {self.input_text} \n{self.tl}:"
|
|
@@ -266,9 +271,7 @@ class Translators:
|
|
| 266 |
|
| 267 |
def LLaMAX(self):
|
| 268 |
pipe = pipeline("text-generation", model="LLaMAX/LLaMAX3-8B")
|
| 269 |
-
messages = [
|
| 270 |
-
{"role": "user", "content": f"Translate the following text from {self.sl} to {self.sl}: {self.input_text}"},
|
| 271 |
-
]
|
| 272 |
return pipe(messages)[0]["generated_text"]
|
| 273 |
|
| 274 |
def LegoMT(self):
|
|
@@ -605,8 +608,8 @@ def translate_text(model_name: str, s_language: str, t_language: str, input_text
|
|
| 605 |
elif model_name == 'Google':
|
| 606 |
translated_text = Translators(model_name, sl, tl, input_text).google()
|
| 607 |
|
| 608 |
-
elif "
|
| 609 |
-
translated_text = Translators(model_name, sl, tl, input_text).
|
| 610 |
|
| 611 |
elif "m2m" in model_name.lower():
|
| 612 |
translated_text = Translators(model_name, sl, tl, input_text).mtom()
|
|
|
|
| 210 |
return translation[0]['translation_text'], message
|
| 211 |
except Exception as error:
|
| 212 |
return f"Error translating with model: {self.model_name}! Try other available language combination or model.", error
|
| 213 |
+
|
| 214 |
+
def salamandraTApipe(self):
|
| 215 |
+
pipe = pipeline("text-generation", model=self.model)
|
| 216 |
+
messages = [f"Translate the following text from {self.sl} into {self.tl}.\n{self.sl}: {self.input_text} \n{self.tl}:"]
|
| 217 |
+
return pipe(messages)[0]["generated_text"]
|
| 218 |
+
|
| 219 |
def salamandraTA(self):
|
| 220 |
# from datetime import datetime
|
| 221 |
text = f"Translate the following text from {self.sl} into {self.tl}.\n{self.sl}: {self.input_text} \n{self.tl}:"
|
|
|
|
| 271 |
|
| 272 |
def LLaMAX(self):
|
| 273 |
pipe = pipeline("text-generation", model="LLaMAX/LLaMAX3-8B")
|
| 274 |
+
messages = [{"role": "user", "content": f"Translate the following text from {self.sl} to {self.sl}: {self.input_text}"}]
|
|
|
|
|
|
|
| 275 |
return pipe(messages)[0]["generated_text"]
|
| 276 |
|
| 277 |
def LegoMT(self):
|
|
|
|
| 608 |
elif model_name == 'Google':
|
| 609 |
translated_text = Translators(model_name, sl, tl, input_text).google()
|
| 610 |
|
| 611 |
+
elif "salamandra" in model_name.lower():
|
| 612 |
+
translated_text = Translators(model_name, sl, tl, input_text).salamandraTApipe()
|
| 613 |
|
| 614 |
elif "m2m" in model_name.lower():
|
| 615 |
translated_text = Translators(model_name, sl, tl, input_text).mtom()
|