Ufoptg commited on
Commit
840164e
·
verified ·
1 Parent(s): 7b5e594

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -5
main.py CHANGED
@@ -501,13 +501,17 @@ async def bing_dalle(item: BingDalle):
501
 
502
  try:
503
  response = await generate_image(item.prompt, item.model)
504
- # Check if response contains the expected data
505
- if 'data' in response and response['data']:
506
- # Assuming the URL is stored in 'url' key of the first item
507
- image_url = response['data'][0]['url']
 
 
 
 
508
  return {"status": "true", "sukuna": {"message": image_url}}
509
  else:
510
- return {"status": "false", "message": f"No image URL found in the {response.data}"}
511
  except BaseException as e:
512
  return {"status": "false", "message": f"Something went wrong: {e}"}
513
 
 
501
 
502
  try:
503
  response = await generate_image(item.prompt, item.model)
504
+ except BaseException as e:
505
+ return {"status": "false", "message": f"Something went wrong: {e}"}
506
+ try:
507
+ image_url = response.data[0].url
508
+ except BaseException as e:
509
+ return {"status": "false", "message": f"No image URL found in the {response} Error: {e}"
510
+
511
+ if image_url is not None:
512
  return {"status": "true", "sukuna": {"message": image_url}}
513
  else:
514
+ return {"status": "false", "message": f"No image URL found in the {response}"}
515
  except BaseException as e:
516
  return {"status": "false", "message": f"Something went wrong: {e}"}
517