from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool import datetime import requests import pytz import yaml from tools.final_answer import FinalAnswerTool from Gradio_UI import GradioUI # Below is an example of a tool that does nothing. Amaze us with your creativity ! #==============================================================================================================================# @tool def get_tourist_place_info(place: str, duration_days: int)-> str : """A tool that provides comprehensive tourist information about a particular tourist place or places, Args: place: the name of the given tourist destination (landmark, city, state, country). duration_days: the no. of days planned for the visit. """ import anthropic client = anthropic.Anthropic() prompt = f""" Provide detailed tourist information about {place} for a {duration_days}-day visit in the following structured format:- 1. **Overview**: Brief introduction of the place. 2. **Best season to visit**: Ideal months and why, including weather details. 3. **Tourist attractions**: Top 5-7 must see attractions with a one-line description of each. 4. **Best places to stay**: 3 accomodation options with budget ranges (budget. mid-range, luxury). 5. *Best way to travel there**: Primary transport options (flight, train, road) with trips. 6. **Local transport**: How to get around once there. 7. **Local cuisine**: 3-5 must try dishes or food experiences. 8. **Travel trips**: 3-4 practical trips (visa, language, currency, customs). Keep each section concise but informative. """ message = client.messages.create( model= "claude-sonnet-4-2025-0514", max_tokens=1000, messages= [{"role": "user", "content": prompt}] ) return message.context[0].text #================================================================================================================================# @tool def travel_plan_creator(place: str, duration_days: int, budget_level: str) -> str: """A tool that creates a detailed day-by-day travel itinerary for a tourist destination. Args: place: the name of the tourist destination (landmark, city, state, country). duration_days: the nop. of days planned for the visit. budget_level: travel budget preference- must be one of: 'budget', 'mid-range', or 'luxury'. """ import anthropic client = anthropic.Anthropic() place_info = get_tourist_place_info(place, duration_days) prompt= f""" Using the following tourist information about {place}: {place_info} Create a detailed {duration_days}-day travel itinerary for a {budget_level} traveller. Structure it as: **Trip summary** - Destination, duration, budget level, estimated total cost range. **Pre-Trip Checklist** - visa, vaccinations, bookings to be made in advance. *Day-by-day itinerary** for each day provide: -Morning, Afternoon, Evening activities. -Recommended meals (breakfast, lunch, dinner spots) -Estimated daily spend. **Accomodation Plan** - Recommended stay options matching the {budget_level} budget. **Transport plan** - How to reach {place} + local commute tips. **Packing essentials** - 5-6 items specific to this destination and season. Make the plan realistic, time-efficient, and enjoyable. """ message = client.messages.create( model= "claude-sonnet-4-20250514", tokens= 1000, messages= [{"role": "user", "content": prompt}] ) return message.content[0].text #===================================================================================================================================# @tool def get_current_time_in_timezone(timezone: str) -> str: """A tool that fetches the current local time in a specified timezone. Args: timezone: A string representing a valid timezone (e.g., 'America/New_York'). """ try: # Create timezone object tz = pytz.timezone(timezone) # Get current time in that timezone local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S") return f"The current local time in {timezone} is: {local_time}" except Exception as e: return f"Error fetching time for timezone '{timezone}': {str(e)}" final_answer = FinalAnswerTool() # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder: # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud' model = HfApiModel( max_tokens=2096, temperature=0.5, model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded custom_role_conversions=None, ) # Import tool from Hub image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True) with open("prompts.yaml", 'r') as stream: prompt_templates = yaml.safe_load(stream) agent = CodeAgent( model=model, tools=[final_answer], ## add your tools here (don't remove final answer) max_steps=6, verbosity_level=1, grammar=None, planning_interval=None, name=None, description=None, prompt_templates=prompt_templates ) GradioUI(agent).launch()