mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
Fix ddgs search
This commit is contained in:
parent
acffc939cf
commit
120eef46e1
1 changed files with 4 additions and 3 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue