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