Fix ddgs search

This commit is contained in:
hlohaus 2025-07-13 13:03:39 +02:00
parent acffc939cf
commit 120eef46e1

View file

@ -10,7 +10,8 @@ import asyncio
# Optional dependencies using the new 'ddgs' package name # Optional dependencies using the new 'ddgs' package name
try: try:
from ddgs import DDGS, DDGSError from ddgs import DDGS
from ddgs.exceptions import DDGSException
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
has_requirements = True has_requirements = True
except ImportError: except ImportError:
@ -312,8 +313,8 @@ def get_search_message(prompt: str, raise_search_exceptions: bool = False, **kwa
result, _ = asyncio.run(do_search(prompt, **kwargs)) result, _ = asyncio.run(do_search(prompt, **kwargs))
return result return result
# Use the new DDGSError exception # Use the new DDGSError exception
except (DDGSError, MissingRequirementsError) as e: except (DDGSException, MissingRequirementsError) as e:
if raise_search_exceptions: if raise_search_exceptions:
raise e raise e
debug.error(f"Couldn't do web search: {e.__class__.__name__}: {e}") debug.error(f"Couldn't do web search:", e)
return prompt return prompt