Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -472,12 +472,7 @@ def gemini_pro(item: GeminiPro):
|
|
472 |
|
473 |
@app.post("/Bing/Dall-E-3")
|
474 |
async def bing_dalle(item: BingDalle):
|
475 |
-
|
476 |
-
BingImages = await BingClient(image_provider=BingCreateImages)
|
477 |
-
except Exception:
|
478 |
-
print("Not awaited")
|
479 |
-
BingImages = BingClient(image_provider=BingCreateImages)
|
480 |
-
|
481 |
try:
|
482 |
set_cookies(
|
483 |
".bing.com",
|
@@ -491,21 +486,20 @@ async def bing_dalle(item: BingDalle):
|
|
491 |
async def generate_image(prompt, model):
|
492 |
try:
|
493 |
response = await BingImages.images.generate(
|
494 |
-
prompt=
|
495 |
model=model,
|
496 |
)
|
|
|
|
|
|
|
|
|
|
|
497 |
except BaseException as e:
|
498 |
return {"status": "false", "message": f"Internal Error: {e}"}
|
499 |
-
|
500 |
-
return response
|
501 |
|
502 |
try:
|
503 |
response = await generate_image(item.prompt, item.model)
|
504 |
-
|
505 |
-
if image_url is not None:
|
506 |
-
return SuccessResponse(status="True", randydev={"message": image_url})
|
507 |
-
else:
|
508 |
-
return {"status": "false", "message": f"No image URL found in the {response}"}
|
509 |
except BaseException as e:
|
510 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|
511 |
|
|
|
472 |
|
473 |
@app.post("/Bing/Dall-E-3")
|
474 |
async def bing_dalle(item: BingDalle):
|
475 |
+
BingImages = BingClient()
|
|
|
|
|
|
|
|
|
|
|
476 |
try:
|
477 |
set_cookies(
|
478 |
".bing.com",
|
|
|
486 |
async def generate_image(prompt, model):
|
487 |
try:
|
488 |
response = await BingImages.images.generate(
|
489 |
+
prompt=prompt,
|
490 |
model=model,
|
491 |
)
|
492 |
+
|
493 |
+
image_url = response.get('data', [])[0].get('url')
|
494 |
+
return {"status": "true", "sukuna": {"message": image_url}}
|
495 |
+
except IndexError:
|
496 |
+
return {"status": "false", "message": "No image URL found in the response"}
|
497 |
except BaseException as e:
|
498 |
return {"status": "false", "message": f"Internal Error: {e}"}
|
|
|
|
|
499 |
|
500 |
try:
|
501 |
response = await generate_image(item.prompt, item.model)
|
502 |
+
return response
|
|
|
|
|
|
|
|
|
503 |
except BaseException as e:
|
504 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|
505 |
|