From 90360ccfa6a547b43b69d3f83e579c49d87643c5 Mon Sep 17 00:00:00 2001 From: kqlio67 <166700875+kqlio67@users.noreply.github.com> Date: Mon, 30 Dec 2024 02:04:06 +0000 Subject: fix: Update deprecated DuckDuckGo search backend from 'api' to 'auto' (#2516) * fix: Update deprecated DuckDuckGo search backend from 'api' to 'auto' Fixes UserWarning: 'api' backend is deprecated, using backend='auto' - Updated default backend parameter from 'api' to 'auto' in search function - Aligns with latest duckduckgo-search library recommendations * Update g4f/Provider/Blackbox.py * Fix response_format=b64_json (g4f/client/__init__.py) * Update g4f/Provider/Blackbox2.py g4f/Provider/BlackboxCreateAgent.py --------- Co-authored-by: kqlio67 <> --- g4f/web_search.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'g4f/web_search.py') diff --git a/g4f/web_search.py b/g4f/web_search.py index 652555b6..5d3c5659 100644 --- a/g4f/web_search.py +++ b/g4f/web_search.py @@ -102,7 +102,7 @@ async def fetch_and_scrape(session: ClientSession, url: str, max_words: int = No except ClientError: return -async def search(query: str, max_results: int = 5, max_words: int = 2500, backend: str = "api", add_text: bool = True, timeout: int = 5, region: str = "wt-wt") -> SearchResults: +async def search(query: str, max_results: int = 5, max_words: int = 2500, backend: str = "auto", add_text: bool = True, timeout: int = 5, region: str = "wt-wt") -> SearchResults: if not has_requirements: raise MissingRequirementsError('Install "duckduckgo-search" and "beautifulsoup4" package | pip install -U g4f[search]') with DDGS() as ddgs: @@ -113,7 +113,7 @@ async def search(query: str, max_results: int = 5, max_words: int = 2500, backen safesearch="moderate", timelimit="y", max_results=max_results, - backend=backend, + backend=backend, # Changed from 'api' to 'auto' ): results.append(SearchResultEntry( result["title"], @@ -169,4 +169,4 @@ def get_search_message(prompt: str, raise_search_exceptions=False, **kwargs) -> if raise_search_exceptions: raise e debug.log(f"Couldn't do web search: {e.__class__.__name__}: {e}") - return prompt \ No newline at end of file + return prompt -- cgit v1.2.3