# DuckDuckGoSearchTool

## ``autogen.tools.experimental.DuckDuckGoSearchTool``

```
DuckDuckGoSearchTool()
```

Bases: `Tool`

DuckDuckGoSearchTool is a tool that uses DuckDuckGo to perform a search.

This tool allows agents to leverage the DuckDuckGo search engine for information retrieval. DuckDuckGo does not require an API key, making it easy to use.

Initializes the DuckDuckGoSearchTool.

Source code in `autogen/tools/experimental/duckduckgo/duckduckgo_search.py`

|     |     |
| --- | --- |
| ```<br> 78<br> 79<br> 80<br> 81<br> 82<br> 83<br> 84<br> 85<br> 86<br> 87<br> 88<br> 89<br> 90<br> 91<br> 92<br> 93<br> 94<br> 95<br> 96<br> 97<br> 98<br> 99<br>100<br>101<br>102<br>103<br>``` | ```<br>def __init__(self) -> None:<br>    """Initializes the DuckDuckGoSearchTool."""<br>    def duckduckgo_search(<br>        query: Annotated[str, "The search query."],<br>        num_results: Annotated[int, "The number of results to return."] = 5,<br>    ) -> list[dict[str, Any]]:<br>        """Performs a search using the DuckDuckGo Search API and returns formatted results.<br>        Args:<br>            query: The search query string.<br>            num_results: The maximum number of results to return. Defaults to 5.<br>        Returns:<br>            A list of dictionaries, each containing 'title', 'link', and 'snippet' of a search result.<br>        """<br>        return _duckduckgo_search(<br>            query=query,<br>            num_results=num_results,<br>        )<br>    super().__init__(<br>        name="duckduckgo_search",<br>        description="Use the DuckDuckGo Search API to perform a search.",<br>        func_or_tool=duckduckgo_search,<br>    )<br>``` |

### ``name`property``

```
name
```

### ``description`property``

```
description
```

### ``func`property``

```
func
```

### ``tool_schema`property``

```
tool_schema
```

Get the schema for the tool.

This is the preferred way of handling function calls with OpenAI and compatible frameworks.

### ``function_schema`property``

```
function_schema
```

Get the schema for the function.

This is the old way of handling function calls with OpenAI and compatible frameworks. It is provided for backward compatibility.

### ``realtime_tool_schema`property``

```
realtime_tool_schema
```

Get the schema for the tool.

This is the preferred way of handling function calls with OpenAI and compatible frameworks.

### ``register_for_llm``

```
register_for_llm(agent)
```

Registers the tool for use with a ConversableAgent's language model (LLM).

This method registers the tool so that it can be invoked by the agent during interactions with the language model.

| PARAMETER | DESCRIPTION |
| --- | --- |
| `agent` | The agent to which the tool will be registered.<br>**TYPE:**`ConversableAgent` |

Source code in `autogen/tools/tool.py`

|     |     |
| --- | --- |
| ```<br> 89<br> 90<br> 91<br> 92<br> 93<br> 94<br> 95<br> 96<br> 97<br> 98<br> 99<br>100<br>101<br>``` | ```<br>def register_for_llm(self, agent: "ConversableAgent") -> None:<br>    """Registers the tool for use with a ConversableAgent's language model (LLM).<br>    This method registers the tool so that it can be invoked by the agent during<br>    interactions with the language model.<br>    Args:<br>        agent (ConversableAgent): The agent to which the tool will be registered.<br>    """<br>    if self._func_schema:<br>        agent.update_tool_signature(self._func_schema, is_remove=False)<br>    else:<br>        agent.register_for_llm()(self)<br>``` |

### ``register_for_execution``

```
register_for_execution(agent)
```

Registers the tool for direct execution by a ConversableAgent.

This method registers the tool so that it can be executed by the agent, typically outside of the context of an LLM interaction.

| PARAMETER | DESCRIPTION |
| --- | --- |
| `agent` | The agent to which the tool will be registered.<br>**TYPE:**`ConversableAgent` |

Source code in `autogen/tools/tool.py`

|     |     |
| --- | --- |
| ```<br>103<br>104<br>105<br>106<br>107<br>108<br>109<br>110<br>111<br>112<br>``` | ```<br>def register_for_execution(self, agent: "ConversableAgent") -> None:<br>    """Registers the tool for direct execution by a ConversableAgent.<br>    This method registers the tool so that it can be executed by the agent,<br>    typically outside of the context of an LLM interaction.<br>    Args:<br>        agent (ConversableAgent): The agent to which the tool will be registered.<br>    """<br>    agent.register_for_execution()(self)<br>``` |

### ``register_tool``

```
register_tool(agent)
```

Register a tool to be both proposed and executed by an agent.

Equivalent to calling both `register_for_llm` and `register_for_execution` with the same agent.

Note: This will not make the agent recommend and execute the call in one step. If the agent recommends the tool, it will need to be the next agent to speak in order to execute the tool.

| PARAMETER | DESCRIPTION |
| --- | --- |
| `agent` | The agent to which the tool will be registered.<br>**TYPE:**`ConversableAgent` |

Source code in `autogen/tools/tool.py`

|     |     |
| --- | --- |
| ```<br>114<br>115<br>116<br>117<br>118<br>119<br>120<br>121<br>122<br>123<br>124<br>125<br>126<br>``` | ```<br>def register_tool(self, agent: "ConversableAgent") -> None:<br>    """Register a tool to be both proposed and executed by an agent.<br>    Equivalent to calling both `register_for_llm` and `register_for_execution` with the same agent.<br>    Note: This will not make the agent recommend and execute the call in one step. If the agent<br>    recommends the tool, it will need to be the next agent to speak in order to execute the tool.<br>    Args:<br>        agent (ConversableAgent): The agent to which the tool will be registered.<br>    """<br>    self.register_for_llm(agent)<br>    self.register_for_execution(agent)<br>``` |

Back to top
