Create random_destination

#504
Files changed (1) hide show
  1. tools/random_destination +63 -0
tools/random_destination ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.tools import tool
2
+ import random
3
+
4
+ # Sample destination data
5
+ destinations = [
6
+ {
7
+ "destination_name": "Kyoto",
8
+ "country": "Japan",
9
+ "best_time_to_visit": "March to May, October to November",
10
+ "climate": "Temperate",
11
+ "currency": "Japanese Yen",
12
+ "fun_facts": "Famous for temples and cherry blossoms.",
13
+ "top_attractions": ["Fushimi Inari Shrine", "Kinkaku-ji", "Arashiyama Bamboo Grove"],
14
+ "continent": "Asia",
15
+ "budget_friendly": False
16
+ },
17
+ {
18
+ "destination_name": "Lisbon",
19
+ "country": "Portugal",
20
+ "best_time_to_visit": "March to October",
21
+ "climate": "Warm Mediterranean",
22
+ "currency": "Euro",
23
+ "fun_facts": "One of the oldest cities in Western Europe.",
24
+ "top_attractions": ["Belém Tower", "Alfama district", "Lisbon Oceanarium"],
25
+ "continent": "Europe",
26
+ "budget_friendly": True
27
+ },
28
+ {
29
+ "destination_name": "Cape Town",
30
+ "country": "South Africa",
31
+ "best_time_to_visit": "March to May, September to November",
32
+ "climate": "Mediterranean",
33
+ "currency": "South African Rand",
34
+ "fun_facts": "Known for Table Mountain and coastal scenery.",
35
+ "top_attractions": ["Table Mountain", "Cape Point", "Robben Island"],
36
+ "continent": "Africa",
37
+ "budget_friendly": True
38
+ },
39
+ # Add more destinations here...
40
+ ]
41
+
42
+ @tool
43
+ def random_travel_destination(
44
+ continent: str = None,
45
+ climate: str = None,
46
+ budget_friendly: bool = None,
47
+ ) -> dict:
48
+ """
49
+ Returns a random travel destination. You can optionally filter by continent, climate, and budget-friendliness.
50
+ """
51
+ filtered = destinations
52
+
53
+ if continent:
54
+ filtered = [d for d in filtered if d["continent"].lower() == continent.lower()]
55
+ if climate:
56
+ filtered = [d for d in filtered if d["climate"].lower() == climate.lower()]
57
+ if budget_friendly is not None:
58
+ filtered = [d for d in filtered if d["budget_friendly"] == budget_friendly]
59
+
60
+ if not filtered:
61
+ return {"error": "No destinations match the selected filters."}
62
+
63
+ return random.choice(filtered)