HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/PraisonAI/docs/agents/wikipedia.mdx
---
title: "Wikipedia Agent"
sidebarTitle: "Wikipedia"
description: "Learn how to create AI agents for searching and extracting information from Wikipedia."
icon: "book"
---

```mermaid
flowchart LR
    In[Query] --> Search[Wiki Search]
    Search --> Page[Page Retrieval]
    Page --> Summary[Content Summary]
    Summary --> Out[Knowledge Output]
    
    style In fill:#8B0000,color:#fff
    style Search fill:#2E8B57,color:#fff
    style Page fill:#2E8B57,color:#fff
    style Summary fill:#2E8B57,color:#fff
    style Out fill:#8B0000,color:#fff
```

A workflow demonstrating how the Wikipedia Agent can search, retrieve, and summarize Wikipedia content.

## Quick Start

<Steps>
    <Step title="Install Package">
        First, install the PraisonAI Agents package:
        ```bash
        pip install praisonaiagents
        ```
    </Step>

    <Step title="Set API Key">
        Set your OpenAI API key as an environment variable:
        ```bash
        export OPENAI_API_KEY=your_api_key_here
        ```
    </Step>

    <Step title="Create Script">
        Create a new file `wikipedia_assistant.py`:
        ```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="WikipediaAssistant",
            role="Wikipedia Research Specialist",
            goal="Extract and summarize Wikipedia content",
            instructions="You are a Wikipedia Agent",
            tools=[
                wiki_search,
                wiki_summary,
                wiki_page,
                wiki_random,
                wiki_language
            ],
            self_reflect=True,
            min_reflect=3,
            max_reflect=5
        )

        # Research a topic
        response = wiki_agent.start("""
            What is the history of AI?
            First search the history of AI
            Read the page of the history of AI
            Get the summary of the page
        """)
        
        # Save research results
        with open('ai_history.md', 'w') as f:
            f.write(response)
        ```
    </Step>
</Steps>

## Understanding Wikipedia Research

The Wikipedia Agent provides comprehensive Wikipedia access through multiple tools:

1. **Wiki Search**: `wiki_search` for finding relevant articles
2. **Page Access**: `wiki_page` for retrieving full articles
3. **Summarization**: `wiki_summary` for concise overviews
4. **Random Articles**: `wiki_random` for discovering content
5. **Language Support**: `wiki_language` for multilingual access

## Features

<CardGroup cols={2}>
  <Card title="Article Search" icon="magnifying-glass">
    Find relevant Wikipedia articles.
  </Card>
  <Card title="Content Retrieval" icon="book-open">
    Access complete article content.
  </Card>
  <Card title="Summarization" icon="compress">
    Generate concise article summaries.
  </Card>
  <Card title="Multilingual" icon="language">
    Access content in multiple languages.
  </Card>
</CardGroup>

## Example Usage

```python
# Example: Research a scientific topic
from praisonaiagents import Agent
from praisonaiagents.tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language

agent = Agent(
    instructions="You are a Wikipedia Agent", 
    tools=[wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language],
    self_reflect=True,
    min_reflect=3,
    max_reflect=5,
)
agent.start(
    "What is the history of AI?"
    "First search the history of AI"
    "Read the page of the history of AI"
    "Get the summary of the page"
)
```

## Next Steps

- Learn about [Prompt Chaining](/features/promptchaining) for complex Wikipedia research
- Explore [Evaluator Optimizer](/features/evaluator-optimiser) for improving research quality
- Check out the [Research Agent](/agents/research) for broader research capabilities