mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2026-01-04 14:24:21 +01:00
fix: rate limiting error
This commit is contained in:
19
src/gpt.py
19
src/gpt.py
@@ -32,13 +32,18 @@ class GPTSession:
|
||||
|
||||
def is_gpt4_available(self):
|
||||
try:
|
||||
openai.ChatCompletion.create(
|
||||
model="gpt-4",
|
||||
messages=[{
|
||||
"role": 'system',
|
||||
"content": 'test'
|
||||
}]
|
||||
)
|
||||
for i in range(5):
|
||||
try:
|
||||
openai.ChatCompletion.create(
|
||||
model="gpt-4",
|
||||
messages=[{
|
||||
"role": 'system',
|
||||
"content": 'test'
|
||||
}]
|
||||
)
|
||||
except RateLimitError:
|
||||
sleep(1)
|
||||
continue
|
||||
return True
|
||||
except openai.error.InvalidRequestError:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user