Spaces:
Runtime error
Runtime error
File size: 2,980 Bytes
32d85ea bb03ea6 32d85ea f0dfd71 32d85ea f0dfd71 32d85ea f0dfd71 f4628fd 32d85ea |
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 65 66 67 68 69 70 71 72 73 74 75 |
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 |