DuckDuckGo enables an Agent to search the web for information.

Prerequisites

The following example requires the duckduckgo-search library. To install DuckDuckGo, run the following command:

pip install -U duckduckgo-search

Example

cookbook/tools/duckduckgo.py
from phi.agent import Agent
from phi.tools.duckduckgo import DuckDuckGo

agent = Agent(tools=[DuckDuckGo()], show_tool_calls=True)
agent.print_response("Whats happening in France?", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
searchboolTrueEnables the use of the duckduckgo_search function to search DuckDuckGo for a query.
newsboolTrueEnables the use of the duckduckgo_news function to fetch the latest news via DuckDuckGo.
fixed_max_resultsint-Sets a fixed number of maximum results to return. No default is provided, must be specified if used.
headersAny-Accepts any type of header values to be sent with HTTP requests.
proxystr-Specifies a single proxy address as a string to be used for the HTTP requests.
proxiesAny-Accepts a dictionary of proxies to be used for HTTP requests.
timeoutint10Sets the timeout for HTTP requests, in seconds.

Toolkit Functions

FunctionDescription
duckduckgo_searchUse this function to search DuckDuckGo for a query.
duckduckgo_newsUse this function to get the latest news from DuckDuckGo.