WikipediaTools enable an Agent to search wikipedia a website and add its contents to the knowledge base.

Prerequisites

The following example requires the wikipedia library.

pip install -U wikipedia

Example

The following agent will run seach wikipedia for “ai” and print the response.

cookbook/tools/wikipedia_tools.py
from phi.agent import Agent
from phi.tools.wikipedia import WikipediaTools

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

Toolkit Params

NameTypeDefaultDescription
knowledge_baseWikipediaKnowledgeBase-The knowledge base associated with Wikipedia, containing various data and resources linked to Wikipedia’s content.

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.

Information