WikipediaAgent
If you need an agent to perform Wikipedia searches and retrieve relevant information, WikipediaAgent
can help you.
Installation
Install AG2 with the LLM model provider and Wikipedia platform extra:
If you have been using autogen
or pyautogen
, you can upgrade using:
or
as pyautogen
, 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.
It utilizes the WikipediaQueryRunTool
to execute searches and fetch information directly from Wikipedia.
Built-In Tools
The WikipediaAgent
has the following in-built tool:
-
WikipediaQueryRunTool
Enables the agent to perform Wikipedia searches and retrieve relevant summaries. -
WikipediaPageLoadTool
Retrieves the full content of a specified Wikipedia page for more in-depth responses.
Platform Configuration
No special configuration is required to use WikipediaAgent
. 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 the WikipediaAgent
to search for information about Australia:
This setup allows the 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, the UserProxyAgent
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.