Wikipedia

Search Wikipedia with WikipediaTools and optionally add results to a Knowledge base.

WikipediaTools enable an Agent to search Wikipedia and add its contents to the knowledge base.

Prerequisites

The following example requires the wikipedia and openai libraries.

uv pip install -U agno wikipedia openai

Example

The following agent will search Wikipedia for "ai" and print the response.

cookbook/91_tools/wikipedia_tools.py
from agno.agent import Agent
from agno.tools.wikipedia import WikipediaTools

agent = Agent(tools=[WikipediaTools()])
agent.print_response("Search wikipedia for 'ai'")

Toolkit Params

NameTypeDefaultDescription
knowledgeOptional[Knowledge]NoneKnowledge base to store Wikipedia content in. When provided, the toolkit registers search_wikipedia_and_update_knowledge_base instead of search_wikipedia.
auto_suggestboolTrueAllow Wikipedia to auto-suggest a matching article title for the query.
allboolFalseCurrently has no effect. Tool registration depends only on knowledge.

Toolkit Functions

Function NameDescription
search_wikipedia_and_update_knowledge_baseThis function searches wikipedia for a topic, adds the results to the knowledge base and returns them.
search_wikipediaSearches Wikipedia for a query.

Developer Resources