Documentation Index Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Python 3.10 or higher
PraisonAI Agents package installed
PraisonAI Tools package installed
newspaper3k package installed
Use Newspaper Tools to extract and analyze news articles with AI agents.
Install Dependencies
First, install the required packages: pip install praisonaiagents praisonai-tools newspaper3k
Import Components
Import the necessary components: from praisonaiagents import Agent , Task , AgentTeam
from praisonai_tools import get_article , get_news_sources , get_articles_from_source , get_trending_topics
Create Agent
Create a news agent: news_agent = Agent (
name = " NewsAgent " ,
role = " News Analyst " ,
goal = " Collect and analyze news articles from various sources. " ,
backstory = " Expert in news gathering and content analysis. " ,
tools =[ get_article , get_news_sources , get_articles_from_source , get_trending_topics ],
reflection = False
)
Define Task
Define the news task: news_task = Task (
description = " Analyze news articles about 'AI developments' from major tech news sources. " ,
expected_output = " Summary of key AI developments with source articles. " ,
agent = news_agent ,
name = " ai_news "
)
Run Agent
Initialize and run the agent: agents = AgentTeam (
agents =[ news_agent ],
tasks =[ news_task ],
process = " sequential "
)
agents . start ()
What are Newspaper Tools? Newspaper Tools provide news article processing capabilities for AI agents:
Article extraction
Source management
Content analysis
Trend detection
Multi-language support
Key Components
News Agent Create specialized news agents: Agent ( tools =[ get_article , get_news_sources , get_articles_from_source , get_trending_topics ])
News Task Define news tasks: Task ( description = " news_query " )
Process Types Sequential or parallel processing:
Article Options Customize article retrieval:
Available Functions
from praisonai_tools import get_article
from praisonai_tools import get_news_sources
from praisonai_tools import get_articles_from_source
from praisonai_tools import get_trending_topics
Examples
Basic News Agent
from praisonaiagents import Agent , Task , AgentTeam
from praisonai_tools import get_article , get_news_sources , get_articles_from_source , get_trending_topics
# Create news agent
news_agent = Agent (
name = " NewsExpert " ,
role = " News Analyst " ,
goal = " Gather and analyze news content efficiently. " ,
backstory = " Expert in news analysis and content curation. " ,
tools =[ get_article , get_news_sources , get_articles_from_source , get_trending_topics ],
reflection = False
)
# Define news task
news_task = Task (
description = " Analyze tech news trends. " ,
expected_output = " Tech news analysis report. " ,
agent = news_agent ,
name = " tech_news_analysis "
)
# Run agent
agents = AgentTeam (
agents =[ news_agent ],
tasks =[ news_task ],
process = " sequential "
)
agents . start ()
Advanced News Analysis with Multiple Agents
from praisonaiagents import Agent , Task , AgentTeam
from praisonai_tools import get_article , get_news_sources , get_articles_from_source , get_trending_topics
# Create news collection agent
collector_agent = Agent (
name = " Collector " ,
role = " News Collector " ,
goal = " Gather comprehensive news coverage. " ,
tools =[ get_article , get_news_sources , get_articles_from_source , get_trending_topics ],
reflection = False
)
# Create analysis agent
analysis_agent = Agent (
name = " Analyzer " ,
role = " Content Analyst " ,
goal = " Analyze news content and identify trends. " ,
backstory = " Expert in news analysis and trend identification. " ,
reflection = False
)
# Define tasks
collection_task = Task (
description = " Collect news articles about renewable energy developments. " ,
agent = collector_agent ,
name = " energy_news "
)
analysis_task = Task (
description = " Analyze the articles and identify key trends and breakthroughs. " ,
agent = analysis_agent ,
name = " news_analysis "
)
# Run agents
agents = AgentTeam (
agents =[ collector_agent , analysis_agent ],
tasks =[ collection_task , analysis_task ],
process = " sequential "
)
agents . start ()
Best Practices
Configure agents with clear news focus: from praisonai_tools import get_article , get_news_sources , get_articles_from_source , get_trending_topics
Agent (
name = " NewsAnalyst " ,
role = " News Specialist " ,
goal = " Analyze news content effectively " ,
tools =[ get_article , get_news_sources , get_articles_from_source , get_trending_topics ]
)
Define specific news objectives: Task (
description = " Analyze tech news from major sources for AI developments " ,
expected_output = " Trend analysis with key findings "
)
Common Patterns
News Monitoring
from praisonaiagents import Agent , Task , AgentTeam
from praisonai_tools import get_article , get_news_sources , get_articles_from_source , get_trending_topics
# News monitor agent
monitor = Agent (
name = " Monitor " ,
role = " News Monitor " ,
tools =[ get_article , get_news_sources , get_articles_from_source , get_trending_topics ]
)
# Analysis agent
analyst = Agent (
name = " Analyst " ,
role = " News Analyst "
)
# Define tasks
monitor_task = Task (
description = " Monitor tech news sources " ,
agent = monitor
)
analysis_task = Task (
description = " Analyze news trends " ,
agent = analyst
)
# Run workflow
agents = AgentTeam (
agents =[ monitor , analyst ],
tasks =[ monitor_task , analysis_task ]
)