Update makeprompt.py

This commit is contained in:
Paillat
2023-02-16 10:47:53 +01:00
parent bc4f029045
commit 1943ba4321

View File

@@ -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