Explorar o código

fix(chat_gpt_bot.py, open_ai_bot.py): increase retry time to 20 seconds when encountering RateLimitError

lanvent %!s(int64=3) %!d(string=hai) anos
pai
achega
abcbb34b1c
Modificáronse 2 ficheiros con 2 adicións e 2 borrados
  1. 1 1
      bot/chatgpt/chat_gpt_bot.py
  2. 1 1
      bot/openai/open_ai_bot.py

+ 1 - 1
bot/chatgpt/chat_gpt_bot.py

@@ -142,7 +142,7 @@ class ChatGPTBot(Bot, OpenAIImage):
                 logger.warn("[CHATGPT] RateLimitError: {}".format(e))
                 result["content"] = "提问太快啦,请休息一下再问我吧"
                 if need_retry:
-                    time.sleep(5)
+                    time.sleep(20)
             elif isinstance(e, openai.error.Timeout):
                 logger.warn("[CHATGPT] Timeout: {}".format(e))
                 result["content"] = "我没有收到你的消息"

+ 1 - 1
bot/openai/open_ai_bot.py

@@ -114,7 +114,7 @@ class OpenAIBot(Bot, OpenAIImage):
                 logger.warn("[OPEN_AI] RateLimitError: {}".format(e))
                 result["content"] = "提问太快啦,请休息一下再问我吧"
                 if need_retry:
-                    time.sleep(5)
+                    time.sleep(20)
             elif isinstance(e, openai.error.Timeout):
                 logger.warn("[OPEN_AI] Timeout: {}".format(e))
                 result["content"] = "我没有收到你的消息"