Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,21 +4,23 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
import json
|
|
|
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
"""A tool that
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
try:
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
return joke
|
| 20 |
except Exception as e:
|
| 21 |
-
return f"Error
|
| 22 |
|
| 23 |
@tool
|
| 24 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -56,7 +58,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 56 |
|
| 57 |
agent = CodeAgent(
|
| 58 |
model=model,
|
| 59 |
-
tools=[
|
| 60 |
max_steps=6,
|
| 61 |
verbosity_level=1,
|
| 62 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
import json
|
| 7 |
+
from googletrans import Translator
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
@tool
|
| 13 |
+
def translate_to_norwegian(text: str) -> str:
|
| 14 |
+
"""A tool that translates the input text to Norwegian using Google Translate.
|
| 15 |
+
Args:
|
| 16 |
+
text: The text to translate.
|
| 17 |
+
"""
|
| 18 |
+
translator = Translator()
|
| 19 |
try:
|
| 20 |
+
translation = translator.translate(text, dest="no")
|
| 21 |
+
return translation.text
|
|
|
|
| 22 |
except Exception as e:
|
| 23 |
+
return f"Error translating text: {str(e)}"
|
| 24 |
|
| 25 |
@tool
|
| 26 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 58 |
|
| 59 |
agent = CodeAgent(
|
| 60 |
model=model,
|
| 61 |
+
tools=[translate_to_norwegian, final_answer], ## add your tools here (don't remove final answer)
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|