From 55df19142fb660eb8f2ed5f67e49d00894ef0e55 Mon Sep 17 00:00:00 2001 From: You Xie Date: Wed, 6 Dec 2023 02:27:22 -0600 Subject: [PATCH] Update chat_gpt_bot.py retry APIConnectionError --- bot/chatgpt/chat_gpt_bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/chatgpt/chat_gpt_bot.py b/bot/chatgpt/chat_gpt_bot.py index 8c9a250..979ce4c 100644 --- a/bot/chatgpt/chat_gpt_bot.py +++ b/bot/chatgpt/chat_gpt_bot.py @@ -148,8 +148,9 @@ class ChatGPTBot(Bot, OpenAIImage): time.sleep(10) elif isinstance(e, openai.error.APIConnectionError): logger.warn("[CHATGPT] APIConnectionError: {}".format(e)) - need_retry = False result["content"] = "我连接不到你的网络" + if need_retry: + time.sleep(5) else: logger.exception("[CHATGPT] Exception: {}".format(e)) need_retry = False