Spaces:
Sleeping
Sleeping
Added a src_lang parameter to the translator tool
Browse files
app.py
CHANGED
|
@@ -9,16 +9,18 @@ from tools.final_answer import FinalAnswerTool
|
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
@tool
|
| 12 |
-
def translate_text(text:str, target_language:str="
|
| 13 |
"""A tool that translates an input text into the preferred target language
|
| 14 |
Args:
|
| 15 |
text: the input text that needs to be translated
|
|
|
|
| 16 |
target_language: the language the input text needs to be translated to
|
| 17 |
"""
|
| 18 |
client = InferenceClient()
|
| 19 |
return client.translation(
|
| 20 |
text,
|
| 21 |
model="facebook/nllb-200-1.3B",
|
|
|
|
| 22 |
tgt_lang=target_language
|
| 23 |
)
|
| 24 |
|
|
|
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
@tool
|
| 12 |
+
def translate_text(text:str, source_language:str, target_language:str="nl")-> str:
|
| 13 |
"""A tool that translates an input text into the preferred target language
|
| 14 |
Args:
|
| 15 |
text: the input text that needs to be translated
|
| 16 |
+
source_language: the language of the input text
|
| 17 |
target_language: the language the input text needs to be translated to
|
| 18 |
"""
|
| 19 |
client = InferenceClient()
|
| 20 |
return client.translation(
|
| 21 |
text,
|
| 22 |
model="facebook/nllb-200-1.3B",
|
| 23 |
+
src_lang=source_language,
|
| 24 |
tgt_lang=target_language
|
| 25 |
)
|
| 26 |
|