From 1943ba43218d8e1fb37273a03a8c555df02f02d4 Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 16 Feb 2023 10:47:53 +0100 Subject: [PATCH] Update makeprompt.py --- code/makeprompt.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/makeprompt.py b/code/makeprompt.py index e91a26d..3b51651 100644 --- a/code/makeprompt.py +++ b/code/makeprompt.py @@ -130,7 +130,7 @@ To include IMAGES, botator does [image:"here a short title of the image"], then openai.api_key = api_key #we can try up to 10 times to get a response from the API response = None - for i in range(10): + for _ in range(10): try: response = await openai.Completion.acreate( engine="text-davinci-003", @@ -145,10 +145,12 @@ To include IMAGES, botator does [image:"here a short title of the image"], then except Exception as e: print(e) - print("Error: when trying to get a response from the API, probably the Rate Limit was reached. Trying again in 15 seconds.") await asyncio.sleep(15) - continue - break # why is break here? if the try block fails, it will continue to the next iteration of the loop, which will try again. if the try block succeeds, it will break out of the loop. so why is break here? + if e == "You exceeded your current quota, please check your plan and billing details.": + await message.channel.send("```diff\n-OPENAI ERROR\nYou exceeded your current quota, please check your plan and billing details.```") + return + else: continue + break response = response["choices"][0]["text"] Images_capital = re.findall(r"\[Image:(.*?)\]", response) #replace all [Image:...] with [image:...] so that we can use the same code for both