Wikipedia Agent

Wikipedia data retrieval tools for AI agents.

python
from praisonaiagents import Agent
from praisonai_tools import wiki_search, wiki_summary, wiki_page

agent = Agent(
    name="WikiResearcher",
    tools=[wiki_search, wiki_summary, wiki_page],
)
agent.start("Summarise the Wikipedia article on machine learning")

The user requests a topic; the agent uses Wikipedia tools to search, fetch, and summarise articles.

Diagram

Input

Agent

Tool

Output

Diagram
Wikipedia AgentAgentUserWikipedia AgentAgentUserRequestProcess requestResultResponse

Wikipedia Tools

Use Wikipedia Tools to retrieve and analyze Wikipedia content with AI agents.

  1. Install Dependencies

    First, install the required packages:

    bash
    pip install praisonaiagents praisonai-tools wikipedia
  2. Import Components

    Import the necessary components:

    python
    from praisonaiagents import Agent, Task, AgentTeam
    from praisonai_tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language
  3. 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],
        reflection=False
    )
  4. 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"
    )
  5. Run Agent

    Initialize and run the agent:

    python
    agents = AgentTeam(
        agents=[wiki_agent],
        tasks=[research_task],
        process="sequential"
    )
    agents.start()

Understanding Wikipedia Tools

What are Wikipedia Tools?

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

Key Components

Available Functions

python
from praisonai_tools import wiki_search
from praisonai_tools import wiki_summary
from praisonai_tools import wiki_page
from praisonai_tools import wiki_random
from praisonai_tools import wiki_language

Examples

Basic Wikipedia Research Agent

python
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_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],
    reflection=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 = AgentTeam(
    agents=[wiki_agent],
    tasks=[research_task],
    process="sequential"
)
agents.start()

Advanced Research with Multiple Agents

python
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language

# Create research agent
researcher_agent = Agent(
    name="Researcher",
    role="Content Researcher",
    goal="Research topics systematically.",
    tools=[wiki_search, wiki_summary, wiki_page],
    reflection=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],
    reflection=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 = AgentTeam(
    agents=[researcher_agent, analysis_agent],
    tasks=[research_task, analysis_task],
    process="sequential"
)
agents.start()

Best Practices

Agent Configuration

Configure agents with clear research focus:

python
from praisonai_tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language

Agent(
    name="WikiResearcher",
    role="Research Specialist",
    goal="Research topics accurately and efficiently",
    tools=[wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language]
)
Task Definition

Define specific research objectives:

python
Task(
    description="Research historical events and gather sources",
    expected_output="Detailed research summary"
)

Common Patterns

Research Pipeline

python
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language

# 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 = AgentTeam(
    agents=[researcher, analyzer],
    tasks=[research_task, analyze_task]
)

Related