happyseas commited on
Commit
4df4ea0
·
verified ·
1 Parent(s): 98555b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -9,15 +9,23 @@ from Gradio_UI import GradioUI
9
 
10
 
11
  @tool
12
- def translate_to_spanish (english:str)-> str:
13
- """A tool that translates text from english to spanish
14
  Args:
15
- english: the text in english to be translated to spanish
 
 
16
 
17
- spanish_text = english.translate()
18
  """
19
- return "spanish_text"
20
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -55,7 +63,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,
 
9
 
10
 
11
  @tool
12
+ def translate_to_spanish (english : str)-> str:
13
+ """A tool that translates text from english to spanish using DuckDuckGoSearchTool
14
  Args:
15
+ english (str): the text in english to be translated to spanish
16
+ Returns:
17
+ str: the text translated into spanish
18
 
 
19
  """
20
+ query = "Please translate the following text into Spanish {english}"
21
 
22
+ # Use a temporary agent for the search (reuse model for efficiency)
23
+ temp_agent = CodeAgent(
24
+ tools=[DuckDuckGoSearchTool()],
25
+ model=model
26
+ )
27
+ results = temp_agent.run(query)
28
+
29
  @tool
30
  def get_current_time_in_timezone(timezone: str) -> str:
31
  """A tool that fetches the current local time in a specified timezone.
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[final_answer, translate_to_spanish, get_current_time_in_timezone, DuckDuckGoSearchTool(), image_generation_tool,], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,