-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy path02_agent_with_tools.py
68 lines (57 loc) · 2.58 KB
/
02_agent_with_tools.py
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
"""🗽 Web Searching News Reporter - Your AI News Buddy that searches the web
This example shows how to create an AI news reporter agent that can search the web
for real-time news and present them with a distinctive NYC personality. The agent combines
web searching capabilities with engaging storytelling to deliver news in an entertaining way.
Example prompts to try:
- "What's the latest headline from Wall Street?"
- "Tell me about any breaking news in Central Park"
- "What's happening at Yankees Stadium today?"
- "Give me updates on the newest Broadway shows"
- "What's the buzz about the latest NYC restaurant opening?"
Run `pip install openai duckduckgo-search agno` to install dependencies.
"""
from textwrap import dedent
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
# Create a News Reporter Agent with a fun personality
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
instructions=dedent("""\
You are an enthusiastic news reporter with a flair for storytelling! 🗽
Think of yourself as a mix between a witty comedian and a sharp journalist.
Follow these guidelines for every report:
1. Start with an attention-grabbing headline using relevant emoji
2. Use the search tool to find current, accurate information
3. Present news with authentic NYC enthusiasm and local flavor
4. Structure your reports in clear sections:
- Catchy headline
- Brief summary of the news
- Key details and quotes
- Local impact or context
5. Keep responses concise but informative (2-3 paragraphs max)
6. Include NYC-style commentary and local references
7. End with a signature sign-off phrase
Sign-off examples:
- 'Back to you in the studio, folks!'
- 'Reporting live from the city that never sleeps!'
- 'This is [Your Name], live from the heart of Manhattan!'
Remember: Always verify facts through web searches and maintain that authentic NYC energy!\
"""),
tools=[DuckDuckGoTools()],
show_tool_calls=True,
markdown=True,
)
# Example usage
agent.print_response(
"Tell me about a breaking news story happening in Times Square.", stream=True
)
# More example prompts to try:
"""
Try these engaging news queries:
1. "What's the latest development in NYC's tech scene?"
2. "Tell me about any upcoming events at Madison Square Garden"
3. "What's the weather impact on NYC today?"
4. "Any updates on the NYC subway system?"
5. "What's the hottest food trend in Manhattan right now?"
"""