File: //opt/PraisonAI/docs/tools/wikipedia_tools.mdx
---
title: "Wikipedia Agent"
description: "Wikipedia data retrieval tools for AI agents."
icon: "book"
---
<Note>
**Prerequisites**
- Python 3.10 or higher
- PraisonAI Agents package installed
- `wikipedia` package installed
- Basic understanding of Wikipedia APIs
</Note>
## Wikipedia Tools
Use Wikipedia Tools to retrieve and analyze Wikipedia content with AI agents.
<Steps>
<Step title="Install Dependencies">
First, install the required packages:
```bash
pip install praisonaiagents wikipedia
```
</Step>
<Step title="Import Components">
Import the necessary components:
```python
from praisonaiagents import Agent, Task, PraisonAIAgents
from praisonaiagents.tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language
```
</Step>
<Step title="Create Agent">
Create a Wikipedia research agent:
```python
wiki_agent = Agent(
name="WikiResearcher",
role="Wikipedia Research Specialist",
goal="Research and analyze Wikipedia content efficiently.",
backstory="Expert in information retrieval and content analysis.",
tools=[wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language],
self_reflect=False
)
```
</Step>
<Step title="Define Task">
Define the research task:
```python
research_task = Task(
description="Research historical events and gather information.",
expected_output="Comprehensive research summary with citations.",
agent=wiki_agent,
name="historical_research"
)
```
</Step>
<Step title="Run Agent">
Initialize and run the agent:
```python
agents = PraisonAIAgents(
agents=[wiki_agent],
tasks=[research_task],
process="sequential"
)
agents.start()
```
</Step>
</Steps>
## Understanding Wikipedia Tools
<Card title="What are Wikipedia Tools?" icon="question">
Wikipedia Tools provide research capabilities for AI agents:
- Article search and retrieval
- Content summary generation
- Full page information access
- Random article discovery
- Multi-language support
</Card>
## Key Components
<CardGroup cols={2}>
<Card title="Wiki Agent" icon="user-robot">
Create specialized research agents:
```python
Agent(tools=[wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language])
```
</Card>
<Card title="Wiki Task" icon="list-check">
Define research tasks:
```python
Task(description="wiki_query")
```
</Card>
<Card title="Process Types" icon="arrows-split-up-and-left">
Sequential or parallel processing:
```python
process="sequential"
```
</Card>
<Card title="Wiki Options" icon="sliders">
Customize search parameters:
```python
language="en", sentences=3
```
</Card>
</CardGroup>
## Examples
### Basic Wikipedia Research Agent
```python
from praisonaiagents import Agent, Task, PraisonAIAgents
from praisonaiagents.tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language
# Create Wikipedia agent
wiki_agent = Agent(
name="WikiExpert",
role="Research Specialist",
goal="Research topics efficiently and accurately.",
backstory="Expert in information gathering and analysis.",
tools=[wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language],
self_reflect=False
)
# Define research task
research_task = Task(
description="Research scientific discoveries and breakthroughs.",
expected_output="Detailed research report with references.",
agent=wiki_agent,
name="science_research"
)
# Run agent
agents = PraisonAIAgents(
agents=[wiki_agent],
tasks=[research_task],
process="sequential"
)
agents.start()
```
### Advanced Research with Multiple Agents
```python
# Create research agent
researcher_agent = Agent(
name="Researcher",
role="Content Researcher",
goal="Research topics systematically.",
tools=[wiki_search, wiki_summary, wiki_page],
self_reflect=False
)
# Create analysis agent
analysis_agent = Agent(
name="Analyzer",
role="Content Analyst",
goal="Analyze and summarize research findings.",
backstory="Expert in content analysis and synthesis.",
tools=[wiki_summary, wiki_page],
self_reflect=False
)
# Define tasks
research_task = Task(
description="Research technological advancements.",
agent=researcher_agent,
name="tech_research"
)
analysis_task = Task(
description="Analyze and synthesize research findings.",
agent=analysis_agent,
name="content_analysis"
)
# Run agents
agents = PraisonAIAgents(
agents=[researcher_agent, analysis_agent],
tasks=[research_task, analysis_task],
process="sequential"
)
agents.start()
```
## Best Practices
<AccordionGroup>
<Accordion title="Agent Configuration">
Configure agents with clear research focus:
```python
Agent(
name="WikiResearcher",
role="Research Specialist",
goal="Research topics accurately and efficiently",
tools=[wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language]
)
```
</Accordion>
<Accordion title="Task Definition">
Define specific research objectives:
```python
Task(
description="Research historical events and gather sources",
expected_output="Detailed research summary"
)
```
</Accordion>
</AccordionGroup>
## Common Patterns
### Research Pipeline
```python
# Research agent
researcher = Agent(
name="Researcher",
role="Wiki Researcher",
tools=[wiki_search, wiki_summary, wiki_page]
)
# Analysis agent
analyzer = Agent(
name="Analyzer",
role="Content Analyzer",
tools=[wiki_summary, wiki_page]
)
# Define tasks
research_task = Task(
description="Research topic",
agent=researcher
)
analyze_task = Task(
description="Analyze findings",
agent=analyzer
)
# Run workflow
agents = PraisonAIAgents(
agents=[researcher, analyzer],
tasks=[research_task, analyze_task]
)