| from transformers.tools import tool |
| import random |
|
|
| |
| 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 |
| }, |
| |
| ] |
|
|
| @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) |
|
|