Wikipedia Agent#
In the Wikipedia Search Tools notebook, we demonstrated how to create Agents with basic Wikipedia search capabilities.
Now, we’re taking it a step further with WikipediaAgent
—a powerful agent equipped with built-in wiki search tools right out of the box!
Package Installation#
To get started with the Wikipedia search integration in AG2, follow these steps:
Install AG2 with "wikipedia
and openai
since we use OpenAI’s LLMs in our example:
Note: If you have been using
autogen
orpyautogen
, all you need to do is upgrade it using:or
as
pyautogen
,autogen
, andag2
are aliases for the same PyPI package.
You’re all set! Now you can start using Wikipedia Search with AG2.
Demonstration#
The WikipediaAgent
comes packaged with two Wikipedia tools, WikipediaQueryRunTool
for running title/keyword searches and WikipediaPageLoadTool
for fetching full page content. Together with the fact that it has a pre-configured system message (which you can override), you only need to create the agent and add it to a chat to get going.
Imports#
Agent Configuration#
Configure WikipediaAgent
and run it. Using the agent’s run
command will automatically
# LLM configuration
config_list = LLMConfig(api_type="openai", model="gpt-4o-mini")
# Create the agent
wiki_agent = WikipediaAgent(name="wiki-agent", llm_config=config_list)
# If you are adding this agent into a chat that requires separate tool execution, register the tools with the executing agent:
# for tool in wiki_agent.tools:
# tool.register_for_execution(the_executing_agent)
Start the Conversation#
With the setup complete, you can now use the conversation.