WikipediaAgent can help you.
Installation
Install AG2 with the LLM model provider and Wikipedia platform extra:autogen or ag2, you can upgrade using:
autogen and ag2 are aliases for the same PyPI package.
Capabilities
WikipediaAgent can:
- Perform searches on Wikipedia using natural language queries.
- Retrieve summaries and relevant information from Wikipedia articles.
- Integrate Wikipedia search results into conversations or workflows.
WikipediaQueryRunTool to execute searches and fetch information directly from Wikipedia.
Built-In Tools
TheWikipediaAgent has the following in-built tool:
- 
WikipediaQueryRunToolEnables the agent to perform Wikipedia searches and retrieve relevant summaries.
- 
WikipediaPageLoadToolRetrieves the full content of a specified Wikipedia page for more in-depth responses.
Platform Configuration
No special configuration is required to useWikipediaAgent. It operates using the Wikipedia API, which is publicly accessible. Ensure that your environment has internet access to allow the agent to fetch data from Wikipedia.
Code Example
Here’s a simple example using theWikipediaAgent to search for information about Australia:
UserProxyAgent to delegate the query to the WikipediaAgent, which then performs the search and returns the information.
Tool Execution
In AG2, tool execution is typically handled by a separate agent that follows the main agent in the conversation. In this example, theUserProxyAgent is responsible for executing the tools registered by the WikipediaAgent. This separation ensures a clear distinction between decision-making (handled by WikipediaAgent) and action execution (handled by UserProxyAgent).
For more details on integrating Wikipedia search tools into your agents, refer to the Wikipedia Search Tools Notebook.