Copy
Ask AI
"""
Wikipedia Tools
=============================
Demonstrates wikipedia tools.
"""
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.tools.wikipedia import WikipediaTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# Example 1: Basic Wikipedia search (without knowledge base)
agent = Agent(
tools=[
WikipediaTools(
enable_search_wikipedia=True,
enable_search_wikipedia_and_update_knowledge_base=False,
)
]
)
# Example 2: Enable all Wikipedia functions
agent_all = Agent(tools=[WikipediaTools(all=True)])
# Example 3: Wikipedia with knowledge base integration
knowledge_base = Knowledge()
kb_agent = Agent(
tools=[
WikipediaTools(
knowledge=knowledge_base,
enable_search_wikipedia=False,
enable_search_wikipedia_and_update_knowledge_base=True,
)
]
)
# Test the agents
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent.print_response(
"Search Wikipedia for 'artificial intelligence'", markdown=True
)
kb_agent.print_response(
"Find information about machine learning and add it to knowledge base",
markdown=True,
)
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python wikipedia_tools.py