diff --git a/lagent/actions/bing_browser.py b/lagent/actions/bing_browser.py index b90f2b85..678d0866 100755 --- a/lagent/actions/bing_browser.py +++ b/lagent/actions/bing_browser.py @@ -50,13 +50,16 @@ def __init__(self, 'researchgate.net', ], **kwargs): + self.proxy = kwargs.get('proxy') + self.timeout = kwargs.get('timeout', 10) super().__init__(topk, black_list) @cached(cache=TTLCache(maxsize=100, ttl=600)) def search(self, query: str, max_retry: int = 3) -> dict: for attempt in range(max_retry): try: - response = self._call_ddgs(query, timeout=20) + response = self._call_ddgs( + query, timeout=self.timeout, proxy=self.proxy) return self._parse_response(response) except Exception as e: logging.exception(str(e)) @@ -91,9 +94,11 @@ def __init__(self, 'youtube.com', 'bilibili.com', 'researchgate.net', - ]): + ], + **kwargs): self.api_key = api_key self.market = region + self.proxy = kwargs.get('proxy') super().__init__(topk, black_list) @cached(cache=TTLCache(maxsize=100, ttl=600)) @@ -114,7 +119,8 @@ def _call_bing_api(self, query: str) -> dict: endpoint = 'https://api.bing.microsoft.com/v7.0/search' params = {'q': query, 'mkt': self.market, 'count': f'{self.topk * 2}'} headers = {'Ocp-Apim-Subscription-Key': self.api_key} - response = requests.get(endpoint, headers=headers, params=params) + response = requests.get( + endpoint, headers=headers, params=params, proxies=self.proxy) response.raise_for_status() return response.json() diff --git a/lagent/agents/__init__.py b/lagent/agents/__init__.py index 46709f6e..1a6f756f 100644 --- a/lagent/agents/__init__.py +++ b/lagent/agents/__init__.py @@ -1,6 +1,5 @@ from .autogpt import * # noqa: F401, F403 from .base_agent import * # noqa: F401, F403 from .internlm2_agent import * # noqa: F401, F403 -from .mindsearch_agent import * # noqa: F401, F403 from .react import * # noqa: F401, F403 from .rewoo import * # noqa: F401, F403