From 2105811da6450a83d729d51c910adc761e0dfb8a Mon Sep 17 00:00:00 2001 From: onukura <26293997+onukura@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:11:33 +0100 Subject: [PATCH] DuckDuckGoSearchTool: add ddgs_kwargs parameter to constructor (#372) * DuckDuckGoSearchTool: add ddgs_kwargs parameter to constructor for flexible configuration --- src/smolagents/default_tools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/smolagents/default_tools.py b/src/smolagents/default_tools.py index 3f3af93..650a30e 100644 --- a/src/smolagents/default_tools.py +++ b/src/smolagents/default_tools.py @@ -106,8 +106,8 @@ class DuckDuckGoSearchTool(Tool): inputs = {"query": {"type": "string", "description": "The search query to perform."}} output_type = "string" - def __init__(self, *args, max_results=10, **kwargs): - super().__init__(*args, **kwargs) + def __init__(self, max_results=10, **kwargs): + super().__init__() self.max_results = max_results try: from duckduckgo_search import DDGS @@ -115,7 +115,7 @@ class DuckDuckGoSearchTool(Tool): raise ImportError( "You must install package `duckduckgo_search` to run this tool: for instance run `pip install duckduckgo-search`." ) from e - self.ddgs = DDGS() + self.ddgs = DDGS(**kwargs) def forward(self, query: str) -> str: results = self.ddgs.text(query, max_results=self.max_results)