dzianisBY commited on
Commit
bb43282
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
 
2
  import datetime
3
  import requests
4
  import pytz
@@ -8,6 +9,21 @@ from tools.final_answer import FinalAnswerTool
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  @tool
12
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
@@ -55,7 +71,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
+ from googletrans import Translator
3
  import datetime
4
  import requests
5
  import pytz
 
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
+
13
+ @tool
14
+ def translate_text(text: str, target_language: str) -> str:
15
+ """A tool that translates text to a specified language.
16
+ Args:
17
+ text: The text to translate.
18
+ target_language: The target language (e.g., 'en', 'ru', 'fr').
19
+ """
20
+ translator = Translator()
21
+ try:
22
+ translated = translator.translate(text, dest=target_language)
23
+ return f"Translated text: {translated.text}"
24
+ except Exception as e:
25
+ return f"Error during translation: {str(e)}"
26
+
27
  @tool
28
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
29
  #Keep this format for the description / args / args description but feel free to modify the tool
 
71
 
72
  agent = CodeAgent(
73
  model=model,
74
+ tools=[final_answer, duckduckgo_search, image_generation_tool, translate_text], ## add your tools here (don't remove final answer)
75
  max_steps=6,
76
  verbosity_level=1,
77
  grammar=None,