from smolagents import CodeAgent from typing import Dict, List, Optional, Any class TourGuideAgent(CodeAgent): """ The Tour Guide Agent specializes in finding popular tourist destinations for a given location using web search. """ def __init__( self, model, tools=None, managed_agents=None, prompt_templates=None, planning_interval=None, max_steps=3, verbosity_level=1, name="TourGuideAgent", description="Recommends popular tourist destinations in a given location", **kwargs ): super().__init__( model=model, tools=tools, managed_agents=managed_agents, prompt_templates=prompt_templates, planning_interval=planning_interval, max_steps=max_steps, verbosity_level=verbosity_level, name=name, description=description, **kwargs ) # Updated agent prompt with explicit instructions to use web search self.system_prompt_extension = """ You are the Tour Guide Agent for Journi, an AI travel companion system. Your expertise is in finding popular tourist attractions and destinations. When given a task from the Coordinator Agent, you MUST: 1. ALWAYS use web_search to get up-to-date information about tourist spots 2. Print the raw search results first 3. Then extract the top 5-7 attractions from the search results 4. Always cite your sources with the URLs from the search results 5. Format your response as a bulleted list with citations For example: ```python # Step 1: Search for tourist attractions search_results = web_search(query=f"top tourist attractions in {destination}") print("Raw search results:") print(search_results) # Step 2: Extract and format information from the search results # Format the information with sources ``` Only report attractions mentioned in the search results, do not make up information. When citing sources, follow these rules: 1. Only cite URLs that actually appear in the web search results 2. Format URLs exactly as they appear in the search results 3. Make sure URLs are properly formatted in markdown: [Description](URL) 4. Do not add any characters inside the URL itself 5. Check that the domain name actually makes sense for the content """ if prompt_templates and "system_prompt" in prompt_templates: prompt_templates["system_prompt"] += self.system_prompt_extension else: if not prompt_templates: prompt_templates = {} prompt_templates["system_prompt"] = self.system_prompt_extension self.prompt_templates = prompt_templates