Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayush0054 committed Jan 2, 2025
1 parent 0730588 commit 10e83a4
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions cookbook/agents/49_media_trend_analysis_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from phi.model.openai import OpenAIChat
from phi.tools.exa import ExaTools
from phi.tools.firecrawl import FirecrawlTools
from phi.tools.duckduckgo import DuckDuckGo


def calculate_start_date(days: int) -> str:
Expand All @@ -21,7 +22,8 @@ def calculate_start_date(days: int) -> str:
model=OpenAIChat(id="gpt-4o"),
tools=[
ExaTools(start_published_date=calculate_start_date(30), type="keyword"),
FirecrawlTools(scrape=True, crawl=False),
DuckDuckGo(),
FirecrawlTools(scrape=True),
],
description=dedent("""\
You are an expert media trend analyst specializing in:
Expand All @@ -36,6 +38,8 @@ def calculate_start_date(days: int) -> str:
"2. Identify key influencers and authoritative sources",
"3. Extract main themes and recurring patterns",
"4. Provide actionable recommendations",
"5. if got sources less then 2, only then scrape them using firecrawl tool, dont crawl it and use them to generate the report",
"6. growth rate should be in percentage , and if not possible dont give growth rate",
],
expected_output=dedent("""\
# Media Trend Analysis Report
Expand All @@ -45,53 +49,38 @@ def calculate_start_date(days: int) -> str:
## Trend Analysis
### Volume Metrics
- Total mentions: {count}
- Peak discussion periods: {dates}
- Growth rate: {percentage}
### Key Themes
1. {Theme 1}
- Frequency: {count}
- Notable mentions: {examples}
2. {Theme 2}
- Frequency: {count}
- Notable mentions: {examples}
- Growth rate: {percentage or dont show this}
## Source Analysis
### Top Sources
1. {Source 1}
- Influence score: {score}
2. {Source 2}
- Influence score: {score}
## Actionable Insights
1. {Insight 1}
- Evidence: {data points}
- Recommended action: {action}
2. {Insight 2}
- Evidence: {data points}
- Recommended action: {action}
## Future Predictions
1. {Prediction 1}
- Supporting evidence: {evidence}
2. {Prediction 2}
- Supporting evidence: {evidence}
## References
{Detailed source list with links}
"""),
markdown=True,
show_tool_calls=True,
add_datetime_to_instructions=True,
save_response_to_file="tmp/trend_analysis_{message}.md",
)

# Example usage:
analysis_prompt = """\
Analyze media trends for:
Keywords: artificial intelligence, AI regulation
Sources: techcrunch.com, wired.com, theverge.com
Keywords: ai agents
Sources: verge.com
"""

agent.print_response(analysis_prompt, stream=True)
Expand Down

0 comments on commit 10e83a4

Please sign in to comment.