DuckDuckGo Search Tool#
The DuckDuckGo search integration allows users to perform real-time web searches within the AG2 framework using the DuckDuckGo search engine. Follow these steps to integrate DuckDuckGoSearchTool
with AG2 Agents.
Configuration#
DuckDuckGo Search does not require an API key, making it simple to set up.
Package Installation#
To get started with the DuckDuckGo Search
integration in AG2, you need to install the necessary package:
Install AG2 with openai
and duckduckgo
extras:
Note: If you have been using
autogen
orag2
, all you need to do is upgrade it using:or
as
autogen
, andag2
are aliases for the same PyPI package.
You’re all set! Now you can start using DuckDuckGo Search with AG2.
Implementation#
The DuckDuckGoSearchTool
enables agents to perform real time web searches.
Imports#
import os
from autogen import AssistantAgent, UserProxyAgent
from autogen.tools.experimental import DuckDuckGoSearchTool
Agent Configuration#
Configure an assistant agent and user proxy to be used for LLM recommendation and execution respectively.
os.environ["AUTOGEN_USE_DOCKER"] = "False"
from autogen import LLMConfig
# Configure your LLM settings. You can use OAI_CONFIG_LIST_sample as a template.
config_list = LLMConfig.from_local("OAI_CONFIG_LIST", api_type="openai", model="gpt-4o-mini")
assistant = AssistantAgent(
name="assistant",
llm_config=config_list,
)
user_proxy = UserProxyAgent(name="user_proxy", human_input_mode="NEVER")
Tool Setup#
# Initialize the DuckDuckGoSearchTool. No API key is needed.
duckduckgo_search_tool = DuckDuckGoSearchTool()
# Register the tool for LLM recommendation and execution.
duckduckgo_search_tool.register_for_llm(assistant)
duckduckgo_search_tool.register_for_execution(user_proxy)
Start the Conversation#
With the setup complete, you can now use the assistant to fetch live web search results using DuckDuckGo.