SoulofSukuna commited on
Commit
3a197e6
1 Parent(s): 3039a9a

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -8
main.py CHANGED
@@ -585,11 +585,12 @@ async def gemini_pro(item: GeminiPro):
585
  )
586
 
587
 
588
- BingImages = BingClient()
589
 
 
590
 
591
  @app.post("/Bing/Dall-E-3")
592
- def bing_dalle(item: BingDalle):
593
  try:
594
  set_cookies(
595
  ".bing.com",
@@ -601,16 +602,21 @@ def bing_dalle(item: BingDalle):
601
  raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
602
 
603
  try:
604
- response = BingImages.images.generate(
605
- prompt=item.prompt,
606
- model=item.model,
607
- )
608
- return {"status": "true", "sukuna": {"url": response.data[0].url}}
 
 
 
 
 
 
609
 
610
  except BaseException as e:
611
  return {"status": "false", "message": f"Something went wrong: {e}"}
612
 
613
-
614
  @app.post("/UFoP/dalle3xl")
615
  def dalle_3xl(
616
  item: Dalle3XL,
 
585
  )
586
 
587
 
588
+ import base64
589
 
590
+ BingImages = BingClient()
591
 
592
  @app.post("/Bing/Dall-E-3")
593
+ async def bing_dalle(item: BingDalle):
594
  try:
595
  set_cookies(
596
  ".bing.com",
 
602
  raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
603
 
604
  try:
605
+ response = await imgclient.images.generate(prompt=query, model="dall-e-3")
606
+ paths = []
607
+ base64_images = []
608
+
609
+ for index, item in enumerate(response.data):
610
+ image_url = item.url
611
+ image_data = requests.get(image_url).content
612
+ base64_image = base64.b64encode(image_data).decode('utf-8')
613
+ base64_images.append(base64_image)
614
+
615
+ return {"status": "true", "sukuna": {"urls": [item.url for item in response.data], "base64_images": base64_images}}
616
 
617
  except BaseException as e:
618
  return {"status": "false", "message": f"Something went wrong: {e}"}
619
 
 
620
  @app.post("/UFoP/dalle3xl")
621
  def dalle_3xl(
622
  item: Dalle3XL,