baskadir commited on
Commit
24fb587
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -33,6 +33,27 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def get_list_of_hotels(location: str, price: int) -> list:
38
+ """Fetches the most suitable 10 hotels in a given location and price range.
39
+
40
+ Args:
41
+ location (str): The city or area where hotels should be searched.
42
+ price (str): The preferred price range (e.g., 'budget', 'mid-range', 'luxury', or '50-100 USD').
43
+
44
+ Returns:
45
+ list: A list of dictionaries containing hotel titles, URLs, and snippets.
46
+ """
47
+ try:
48
+ query = f"best hotels in {location} in {price} range"
49
+
50
+ with DuckDuckGoSearchTool as ddgs:
51
+ results = ddgs.text(query, max_results=10)
52
+
53
+ hotels = [{"title": r["title"], "url": r["href"], "snippet": r["body"]} for r in results]
54
+ return hotels
55
+ except Exception as e:
56
+ return [{"error": f"Failed to fetch hotels": {srt(e)}}]
57
 
58
  final_answer = FinalAnswerTool()
59