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

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -9
main.py CHANGED
@@ -25,6 +25,7 @@ import logging
25
  import os
26
  import random
27
  import re
 
28
  from base64 import b64decode
29
  from base64 import b64decode as kc
30
  from datetime import datetime as dt
@@ -584,12 +585,10 @@ async def gemini_pro(item: GeminiPro):
584
  status="False", randydev={"message": contact_support}
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 +600,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,
 
25
  import os
26
  import random
27
  import re
28
+ import base64
29
  from base64 import b64decode
30
  from base64 import b64decode as kc
31
  from datetime import datetime as dt
 
585
  status="False", randydev={"message": contact_support}
586
  )
587
 
 
588
  BingImages = BingClient()
589
 
 
590
  @app.post("/Bing/Dall-E-3")
591
+ async def bing_dalle(item: BingDalle):
592
  try:
593
  set_cookies(
594
  ".bing.com",
 
600
  raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
601
 
602
  try:
603
+ response = await imgclient.images.generate(prompt=query, model="dall-e-3")
604
+ paths = []
605
+ base64_images = []
606
+
607
+ for index, item in enumerate(response.data):
608
+ image_url = item.url
609
+ image_data = requests.get(image_url).content
610
+ base64_image = base64.b64encode(image_data).decode('utf-8')
611
+ base64_images.append(base64_image)
612
+
613
+ return {"status": "true", "sukuna": {"urls": [item.url for item in response.data], "base64_images": base64_images}}
614
 
615
  except BaseException as e:
616
  return {"status": "false", "message": f"Something went wrong: {e}"}
617
 
 
618
  @app.post("/UFoP/dalle3xl")
619
  def dalle_3xl(
620
  item: Dalle3XL,