From 22c7f8fe9e09fb8794476a748427be774a010251 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 30 Mar 2024 01:07:52 +0800 Subject: [PATCH] add dall-e-2 retry_count limit --- bot/chatgpt/chat_gpt_bot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bot/chatgpt/chat_gpt_bot.py b/bot/chatgpt/chat_gpt_bot.py index 0ae02d3..8f71107 100644 --- a/bot/chatgpt/chat_gpt_bot.py +++ b/bot/chatgpt/chat_gpt_bot.py @@ -187,8 +187,11 @@ class AzureChatGPTBot(ChatGPTBot): operation_location = submission.headers['operation-location'] status = "" while (status != "succeeded"): + if retry_count > 3: + return False, "图片生成失败" response = requests.get(operation_location, headers=headers) status = response.json()['status'] + retry_count += 1 image_url = response.json()['result']['data'][0]['url'] return True, image_url except Exception as e: