mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 06:24:20 +01:00
Implements handling of OpenAI rate limit error.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import time
|
||||
import openai
|
||||
import keys
|
||||
|
||||
@@ -18,6 +19,8 @@ def create_chat_message(role, content):
|
||||
return {"role": role, "content": content}
|
||||
|
||||
def chat_with_ai(prompt, user_input, full_message_history, permanent_memory, token_limit, debug = False):
|
||||
while True:
|
||||
try:
|
||||
"""
|
||||
Interact with the OpenAI API, sending the prompt, user input, message history, and permanent memory.
|
||||
|
||||
@@ -57,3 +60,6 @@ def chat_with_ai(prompt, user_input, full_message_history, permanent_memory, tok
|
||||
full_message_history.append(create_chat_message("assistant", assistant_reply))
|
||||
|
||||
return assistant_reply
|
||||
except openai.RateLimitError:
|
||||
print("Error: ", "API Rate Limit Reached. Waiting 60 seconds...")
|
||||
time.sleep(60)
|
||||
|
||||
Reference in New Issue
Block a user