LuOsorio commited on
Commit
292c55f
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -9,14 +9,31 @@ 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
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
 
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -55,7 +72,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
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def get_cities_in_timezone(timezone: str) -> list[str]:
13
+ """A tool that fetches a list of cities in a specified timezone.
14
+
15
  Args:
16
+ timezone: A string representing a valid timezone (e.g., 'America/New_York').
17
+
18
+ Returns:
19
+ A list of cities in the specified timezone or an error message.
20
  """
21
+ search_tool = DuckDuckGoSearchResults()
22
+
23
+ # Make a query to DuckDuckGo
24
+ query = f"cities in {timezone} timezone"
25
+ search_results = search_tool.run(query)
26
+
27
+ # Process the search results to extract city names
28
+ cities = []
29
+ for result in search_results:
30
+ if 'Text' in result:
31
+ cities.append(result['Text'])
32
+
33
+ if not cities:
34
+ return [f"No cities found for the specified timezone '{timezone}'."]
35
+
36
+ return cities
37
 
38
  @tool
39
  def get_current_time_in_timezone(timezone: str) -> str:
 
72
 
73
  agent = CodeAgent(
74
  model=model,
75
+ tools=[final_answer, get_current_time_in_timezone, get_cities_in_timezone], ## add your tools here (don't remove final answer)
76
  max_steps=6,
77
  verbosity_level=1,
78
  grammar=None,