jeipollack commited on
Commit
d4ddfdb
·
verified ·
1 Parent(s): 0ae2bef

Remove datetime and restructure query filters

Browse files
Files changed (1) hide show
  1. app.py +7 -18
app.py CHANGED
@@ -14,7 +14,6 @@ search_tool = DuckDuckGoSearchTool()
14
  def find_open_restaurants_by_location(location: str,
15
  cuisine: str = None,
16
  rating: float = None,
17
- timezone: str = None,
18
  number_of_options: int = 5
19
  )-> str:
20
  """A tool that searches for restaurants according to location, cuisine, rating and local time.
@@ -22,26 +21,16 @@ def find_open_restaurants_by_location(location: str,
22
  location: A string representing the location area with the optional inclusion of a zip code to search for open restaurants (e.g. Paris, Paris 75005, London, London NW1 4RY).
23
  cuisine: An optional string representing the cuisine type (e.g. Asian, Indian, Italian, breakfast, lunch, etc.)
24
  rating: An optional float representing the average customer rating of the restaurant from Google, TripAdvisor, or Yelp.
25
- timezone: An optional string representing a valid timezone (e.g., 'America/New_York').
26
  number_of_options: An integer representing the number of return options, default set to 5.
27
  """
28
  try:
29
- # If no timezone is provided, default to UTC
30
- if timezone:
31
- tz = pytz.timezone(timezone)
32
- else:
33
- tz = pytz.utc # Default timezone
34
- local_time = datetime.datetime.now(tz).strftime("%H:%M")
35
-
36
  # Build query dynamically based on provided inputs
37
- query_parts = [f"restaurants open in {location}"]
38
-
39
- if cuisine:
40
- query_parts.append(f"serving {cuisine} cuisine")
41
- if rating:
42
- query_parts.append(f"with a rating of {rating} or higher")
43
-
44
- query = " ".join(query_parts) # Construct final query
45
  search_results = search_tool(query)
46
 
47
  if not search_results:
@@ -55,7 +44,7 @@ def find_open_restaurants_by_location(location: str,
55
  else:
56
  results_str = str(search_results) # Convert to string if it's not a list
57
 
58
- return f"🍽️ Open restaurants in {location} at {local_time}:\n\n{results_str}"
59
 
60
  except Exception as e:
61
  return f"❌ Error finding restaurants: {str(e)}"
 
14
  def find_open_restaurants_by_location(location: str,
15
  cuisine: str = None,
16
  rating: float = None,
 
17
  number_of_options: int = 5
18
  )-> str:
19
  """A tool that searches for restaurants according to location, cuisine, rating and local time.
 
21
  location: A string representing the location area with the optional inclusion of a zip code to search for open restaurants (e.g. Paris, Paris 75005, London, London NW1 4RY).
22
  cuisine: An optional string representing the cuisine type (e.g. Asian, Indian, Italian, breakfast, lunch, etc.)
23
  rating: An optional float representing the average customer rating of the restaurant from Google, TripAdvisor, or Yelp.
 
24
  number_of_options: An integer representing the number of return options, default set to 5.
25
  """
26
  try:
 
 
 
 
 
 
 
27
  # Build query dynamically based on provided inputs
28
+ query_parts = [
29
+ f"restaurants open now in {location}",
30
+ f"serving {cuisine} cuisine" if cuisine else "",
31
+ f"rated {rating} or higher" if rating else "",
32
+ ]
33
+ query = " ".join(filter(None, query_parts))
 
 
34
  search_results = search_tool(query)
35
 
36
  if not search_results:
 
44
  else:
45
  results_str = str(search_results) # Convert to string if it's not a list
46
 
47
+ return f"🍽️ Open restaurants in {location}:\n\n{results_str}"
48
 
49
  except Exception as e:
50
  return f"❌ Error finding restaurants: {str(e)}"