Skip to content

Commit

Permalink
detect content error from dalle3
Browse files Browse the repository at this point in the history
  • Loading branch information
bghira committed Apr 18, 2024
1 parent dc7825b commit d779c3b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions discord_tron_master/classes/openai/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,14 @@ async def dalle_image_generate(self, prompt, user_config: dict):
if "error" in response:
logging.error(f"Error generating image: {response}")
raise Exception(f'{response["error"]["code"]}: {response["error"]["message"]}')
else:
logging.debug(f"Received response from OpenAI image endpoint: {response}")

url = response.data[0].url
logging.debug(f"Retrieving URL: {url}")
# retrieve URL, return Image
image_obj = await self.retrieve_image(url)
logging.debug(f"Result: {image_obj}")
if not hasattr(image_obj, "size"):
logging.error(f"Image object does not have a size attribute. Returning None.")
logging.debug(f"Response from OpenAI: {response}")
Expand Down

0 comments on commit d779c3b

Please sign in to comment.