Update app with new tools

#1
by jeipollack - opened
Files changed (1) hide show
  1. app.py +28 -7
app.py CHANGED
@@ -9,14 +9,35 @@ 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 +76,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 find_open_restaurants(location:str, timezone:str)-> str: #it's import to specify the return type
13
+ """
14
+ Finds restaurants currently open in a specified location.
15
+
16
  Args:
17
+ location (str): The city or area to search in.
18
+ timezone (str): The timezone of the location (e.g., 'America/New_York').
19
+
20
+ Returns:
21
+ str: A list of currently open restaurants.
22
  """
23
+ try:
24
+ # Get the current local time
25
+ tz = pytz.timezone(timezone)
26
+ local_time = datetime.datetime.now(tz).strftime("%H:%M")
27
+
28
+ # Search for restaurants open now
29
+ query = f"restaurants open now in {location}"
30
+ search_results = search_tool(query)
31
+
32
+ if not search_results:
33
+ return f"❌ No open restaurants found for {location} at {local_time}."
34
+
35
+ return f"🍽️ Open restaurants in {location} at {local_time}:\n\n" + "\n".join(
36
+ [result["title"] + " - " + result["url"] for result in search_results[:5]]
37
+ )
38
+
39
+ except Exception as e:
40
+ return f"❌ Error finding restaurants: {str(e)}"
41
 
42
  @tool
43
  def get_current_time_in_timezone(timezone: str) -> str:
 
76
 
77
  agent = CodeAgent(
78
  model=model,
79
+ tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
80
  max_steps=6,
81
  verbosity_level=1,
82
  grammar=None,