Wikipedia Search Tool

Guide for using the Wikipedia Search tool with PraisonAI agents.

The Wikipedia Search tool lets an agent look up and retrieve encyclopedic facts from Wikipedia.

Diagram

Wikipedia Search

User

Agent

WikipediaAPIWrapper

Wikipedia API

Articles

Overview

The Wikipedia Search tool is a tool that allows you to search and retrieve information from Wikipedia.

bash
pip install langchain-community
export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
python
from praisonaiagents import Agent, AgentTeam
from langchain_community.utilities import WikipediaAPIWrapper

data_agent = Agent(instructions="Gather all of Messi's record in LaLiga", tools=[WikipediaAPIWrapper])
summarise_agent = Agent(instructions="Summarize the data into a well structured format")
agents = AgentTeam(agents=[data_agent, summarise_agent])
agents.start()

How It Works

Diagram
Wikipedia APIWikipediaAPIWrapperAgentUserWikipedia APIWikipediaAPIWrapperAgentUser“Look up X”run(query)HTTPS requestarticle summaryparsed resultfinal answer

Getting Started

  1. Simple Usage
    1. Install dependencies (see Overview above)
    2. Set required API keys in your environment
    3. Run the agent example in Overview
  2. With Configuration

    Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.

Best Practices

No provider key needed

Wikipedia search is free — only OPENAI_API_KEY for the agent’s LLM is required. WikipediaAPIWrapper needs no API key.

Limit returned characters

WikipediaAPIWrapper accepts doc_content_chars_max. Cap it so long articles do not overflow the agent’s context window.

Disambiguate queries

Ambiguous terms return the wrong page. Feed the agent specific titles (e.g. “Lionel Messi”) so results match intent.

Related Tools