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

Quick Start

1

Install Package

First, install the PraisonAI Agents package:

pip install praisonaiagents
2

Set API Key

Set your OpenAI API key as an environment variable:

export OPENAI_API_KEY=your_api_key_here
3

Create Script

Create a new file wikipedia_assistant.py:

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)

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

Article Search

Find relevant Wikipedia articles.

Content Retrieval

Access complete article content.

Summarization

Generate concise article summaries.

Multilingual

Access content in multiple languages.

Example Usage

# 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

Was this page helpful?