Tool

Access Wikipedia Content for Agents

Wikipedia Tool fetches and searches Wikipedia content for LlamaIndex agents.

Works with wikipediaopenai

74
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Integrate Wikipedia's vast knowledge base into your AI agent. This tool allows agents to directly search for and retrieve information from Wikipedia, enabling more informed and comprehensive responses.

Outcomes

What it gets done

01

Search Wikipedia for specific topics or entities.

02

Load and retrieve the content of specific Wikipedia pages.

03

Provide structured Wikipedia data to AI agents for further processing.

04

Enhance agent knowledge with real-time information from Wikipedia.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-wikipedia | bash

Overview

Wikipedia Tool

Wikipedia Tool is a LlamaIndex integration that fetches content from Wikipedia and makes it available to AI agents. It provides two functions: load_data to retrieve specific Wikipedia pages, and search_data to search Wikipedia and load all matching pages. The tool is designed to work as a Tool within LlamaIndex agent workflows. Use this tool when building LlamaIndex agents that need to fetch content from Wikipedia. The tool is designed to be used as a way to load data as a Tool in an Agent.

What it does

Wikipedia Tool integrates Wikipedia content into LlamaIndex agents. It provides two functions: load_data loads a page from Wikipedia, and search_data searches Wikipedia for a query and loads all matching pages.

When to use - and when NOT to

Use Wikipedia Tool when building LlamaIndex agents that need to fetch content from Wikipedia. The tool is designed to be used as a way to load data as a Tool in an Agent.

Consider whether Wikipedia content meets your specific requirements before implementing this tool.

Inputs and outputs

You provide either a specific Wikipedia page title to load directly via load_data, or a search query string via search_data that loads all matching Wikipedia pages. The tool fetches content from Wikipedia and makes it available to the agent.

Integrations

This tool integrates with LlamaIndex's FunctionAgent and agent workflow system. It works alongside OpenAI language models to create agents that can retrieve Wikipedia content. The tool is designed specifically as a LlamaIndex Tool, following the framework's tool specification pattern for agent integration.

Here's how to set up a Wikipedia-enabled agent:

from llama_index.tools.wikipedia import WikipediaToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

tool_spec = WikipediaToolSpec()

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(), llm=OpenAI(model="gpt-4.1")
)

print(await agent.run("Who is Ben Afflecks spouse?"))

Who it's for

This tool is designed for developers building LlamaIndex-based agents. If you're working with LlamaIndex and need to load data from Wikipedia as a Tool in an Agent, this tool provides that capability.

Source README

Wikipedia Tool

This tool fetches content from wikipedia and makes it available to the agent as a Tool. You can search for pages or load pages directly.

Usage

This tool has more extensive example usage documented in a Jupyter notebook here

from llama_index.tools.wikipedia import WikipediaToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

tool_spec = WikipediaToolSpec()

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(), llm=OpenAI(model="gpt-4.1")
)

print(await agent.run("Who is Ben Afflecks spouse?"))

load_data: Loads a page from wikipedia
search_data: Searches wikipedia for a query and loads all matching pages

This loader is designed to be used as a way to load data as a Tool in a Agent.
See this LlamaIndex tutorial for examples.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.