Skip to content

Commit

Permalink
Catch openai RatelimitError
Browse files Browse the repository at this point in the history
  • Loading branch information
thatDudo committed Nov 7, 2023
1 parent c03cfb7 commit 72b31cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion manga_translator/translators/chatgpt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import requests
import openai.error
import litellm
import litellm.exceptions
import asyncio
Expand Down Expand Up @@ -147,7 +148,7 @@ async def _translate(self, from_lang: str, to_lang: str, queries: List[str]) ->
try:
response = await request_task
break
except litellm.exceptions.RateLimitError: # Server returned ratelimit response
except litellm.exceptions.RateLimitError or openai.error.RateLimitError: # Server returned ratelimit response
ratelimit_attempt += 1
if ratelimit_attempt >= self._RATELIMIT_RETRY_ATTEMPTS:
raise
Expand Down

0 comments on commit 72b31cb

Please sign in to comment.