Ufoptg commited on
Commit
a3ec3ae
·
verified ·
1 Parent(s): 10a5fe0

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -5
main.py CHANGED
@@ -481,18 +481,19 @@ async def bing_dalle(item: BingDalle):
481
  except requests.exceptions.RequestException:
482
  raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
483
 
484
- async def generate_image():
485
  try:
486
  response = BingImages.images.generate(
487
- prompt=item.prompt,
488
- model=item.model,
489
  )
490
  except BaseException as e:
491
  return {"status": "false", "message": f"Internal Error: {e}"}
492
  return response
493
  try:
494
- response = await generate_image()
495
- return {"status": "true", "sukuna": {"message": response.data[0].url}}
 
496
  except BaseException as e:
497
  return {"status": "false", "message": f"Something went wrong: {e}"}
498
 
 
481
  except requests.exceptions.RequestException:
482
  raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
483
 
484
+ async def generate_image(prompt, model):
485
  try:
486
  response = BingImages.images.generate(
487
+ prompt=prompt,
488
+ model=model,
489
  )
490
  except BaseException as e:
491
  return {"status": "false", "message": f"Internal Error: {e}"}
492
  return response
493
  try:
494
+ response = await generate_image(item.prompt, item.model)
495
+ image_url = response.data[0].url
496
+ return {"status": "true", "sukuna": {"message": image_url}}
497
  except BaseException as e:
498
  return {"status": "false", "message": f"Something went wrong: {e}"}
499