> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Wikipedia PraisonAI Integration

> Guide for integrating Wikipedia search capabilities with PraisonAI agents using the Wikipedia API wrapper

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="WikiAgent",
    instructions="Search Wikipedia for factual information.",
)
agent.start("Explain the history of the internet")
```

The user asks for encyclopaedic facts; the agent searches Wikipedia and returns a grounded summary.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> T[Tool]
    T --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
    class T tool
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Wikipedia PraisonAI Integration

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

# Wikipedia PraisonAI Integration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install wikipedia langchain_community
```

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# tools.py
from langchain_community.utilities import WikipediaAPIWrapper
class WikipediaSearchTool(BaseTool):
    name: str = "WikipediaSearchTool"
    description: str = "Search Wikipedia for relevant information based on a query."

    def _run(self, query: str):
        api_wrapper = WikipediaAPIWrapper(top_k_results=4, doc_content_chars_max=100)
        results = api_wrapper.load(query=query)
        return results
```

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# agents.yaml
framework: crewai
topic: research about nvidia growth
agents:  # Canonical: use 'agents' instead of 'roles'
  data_collector:
    instructions:  # Canonical: use 'instructions' instead of 'backstory' An experienced researcher with the ability to efficiently collect and
      organize vast amounts of data.
    goal: Gather information on Nvidia's growth by providing the Ticket Symbol to YahooFinanceNewsTool
    role: Data Collector
    tasks:
      data_collection_task:
        description: Collect data on Nvidia's growth from various sources such as
          financial reports, news articles, and company announcements.
        expected_output: A comprehensive document detailing data points on Nvidia's
          growth over the years.
    tools:
    - 'WikipediaSearchTool'
```

## Quick Start

<Steps>
  <Step title="Install">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonaiagents wikipedia-api
    ```
  </Step>

  <Step title="Search Wikipedia with agent">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="WikiAgent",
        instructions="Search Wikipedia for factual information.",
    )

    agent.start("Explain the history of the internet")
    ```
  </Step>
</Steps>

## Best Practices

<AccordionGroup>
  <Accordion title="Use Wikipedia for factual background">
    Wikipedia tools are best for general knowledge and background context, not breaking news.
  </Accordion>

  <Accordion title="Extract specific sections">
    Extract specific sections rather than full articles to reduce token usage.
  </Accordion>

  <Accordion title="Follow links for depth">
    Use Wikipedia link extraction to discover and follow related concepts.
  </Accordion>

  <Accordion title="Pair with web search for recency">
    Combine Wikipedia (background facts) with web search (recent information) for comprehensive research.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
