Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -472,7 +472,6 @@ def gemini_pro(item: GeminiPro):
|
|
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",
|
@@ -483,23 +482,13 @@ async def bing_dalle(item: BingDalle):
|
|
483 |
except requests.exceptions.RequestException:
|
484 |
raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
|
485 |
|
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 =
|
502 |
-
|
|
|
|
|
|
|
|
|
503 |
except BaseException as e:
|
504 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|
505 |
|
|
|
472 |
|
473 |
@app.post("/Bing/Dall-E-3")
|
474 |
async def bing_dalle(item: BingDalle):
|
|
|
475 |
try:
|
476 |
set_cookies(
|
477 |
".bing.com",
|
|
|
482 |
except requests.exceptions.RequestException:
|
483 |
raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
|
484 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
try:
|
486 |
+
response = BingImages.images.generate(
|
487 |
+
prompt=item.prompt,
|
488 |
+
model=item.model,
|
489 |
+
)
|
490 |
+
return {"status": "true", "sukuna": {"message": response.data[0].url}}
|
491 |
+
|
492 |
except BaseException as e:
|
493 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|
494 |
|