DuckDuckGo PraisonAI Integration

Guide for integrating DuckDuckGo search capabilities with PraisonAI agents for web search functionality

python
from praisonaiagents import Agent, duckduckgo

agent = Agent(name="Researcher", tools=[duckduckgo])
agent.start("What are the latest AI developments?")

The user asks for current information; the agent searches the web with DuckDuckGo and cites findings.

Diagram

Input

Agent

Tool

Output

Diagram
DuckDuckGo PraisonAI IntegrationAgentUserDuckDuckGo PraisonAI IntegrationAgentUserRequestProcess requestResultResponse

DuckDuckGo Praison AI Integration

bash
pip install duckduckgo_search

Create a file called tools.py in the same directory as the agents.yaml file.

python
# example tools.py
from duckduckgo_search import DDGS
from praisonai_tools import BaseTool

class InternetSearchTool(BaseTool):
    name: str = "InternetSearchTool"
    description: str = "Search Internet for relevant information based on a query or latest news"

    def _run(self, query: str):
        ddgs = DDGS()
        results = ddgs.text(keywords=query, region='wt-wt', safesearch='moderate', max_results=5)
        return results

Quick Start

  1. Install
    bash
    pip install duckduckgo_search praisonaiagents
  2. Search with agent
    python
    from praisonaiagents import Agent, search_web
    
    agent = Agent(
        name="SearchAgent",
        instructions="Search the web to answer questions.",
        tools=[search_web],
    )
    
    agent.start("What are the latest AI developments?")

Best Practices

Use as a free fallback

DuckDuckGo requires no API key – use it as the zero-cost fallback provider in search_web.

Keep max_results small

DuckDuckGo returns best results in the first 5 hits – higher limits add noise.

Use the unified search_web tool

Prefer from praisonaiagents import search_web for automatic fallback across providers.

Use specific queries

Use specific, descriptive queries rather than broad terms for better DuckDuckGo results.

Related