Skip to content

Commit

Permalink
FIX: added a delay between retries in !gpt3 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
dborodin836 authored Apr 22, 2023
1 parent 6a1f14d commit 5305849
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/chatgpt.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from typing import Literal

import openai
Expand Down Expand Up @@ -44,6 +45,7 @@ def handle_gpt_request(message_type: Literal["CHAT", "GPT3"], username: str, use
break
except openai.error.RateLimitError:
log_cmd_message("Rate limited! Trying again...")
time.sleep(2)
attempts += 1
except Exception:
log_cmd_message("Unhandled error happened! Trying again...")
Expand Down

0 comments on commit 5305849

Please sign in to comment.