Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Handle rate limit exception (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricklamers authored Dec 22, 2023
1 parent 9db9256 commit 2e2324b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from openassistants.data_models.function_output import FunctionOutput, TextOutput
from openassistants.functions.base import BaseFunction, FunctionExecutionDependency
from openassistants.functions.utils import AsyncStreamVersion

from duckduckgo_search.exceptions import RateLimitException

def ddgs_text(query: str, max_results: Optional[int] = None) -> List[Dict[str, str]]:
"""Run query through DuckDuckGo text search and return results."""
Expand Down Expand Up @@ -47,7 +47,7 @@ async def execute(

try:
results = ddgs_text(query, max_results=4)
except RuntimeError:
except RateLimitException:
yield [TextOutput(text="DuckDuckGo is currently unavailable, please try again later.")]
return

Expand Down

0 comments on commit 2e2324b

Please sign in to comment.