Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -107,7 +107,7 @@ app = FastAPI(
|
|
107 |
)
|
108 |
|
109 |
trans = SyncTranslator()
|
110 |
-
|
111 |
|
112 |
timeout = 100
|
113 |
contact_support = """
|
@@ -472,7 +472,8 @@ def gemini_pro(item: GeminiPro):
|
|
472 |
|
473 |
@app.post("/Bing/Dall-E-3")
|
474 |
async def bing_dalle(item: BingDalle):
|
475 |
-
|
|
|
476 |
set_cookies(
|
477 |
".bing.com",
|
478 |
{
|
@@ -482,22 +483,19 @@ async def bing_dalle(item: BingDalle):
|
|
482 |
except requests.exceptions.RequestException:
|
483 |
raise HTTPException(status_code=500, detail="Invalid cookie string, check your cookie string and try again")
|
484 |
|
485 |
-
async def generate_image(
|
486 |
try:
|
487 |
-
response = await
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
image_url = image_data[0].get('url')
|
492 |
-
return {"status": "true", "sukuna": {"message": image_url}}
|
493 |
-
else:
|
494 |
-
return {"status": "false", "message": "No image URL found in the response"}
|
495 |
except BaseException as e:
|
496 |
return {"status": "false", "message": f"Internal Error: {e}"}
|
497 |
-
|
498 |
-
try:
|
499 |
-
response = await generate_image(item.model, item.prompt)
|
500 |
return response
|
|
|
|
|
|
|
|
|
501 |
except BaseException as e:
|
502 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|
503 |
|
|
|
107 |
)
|
108 |
|
109 |
trans = SyncTranslator()
|
110 |
+
BingImage = BingClient()
|
111 |
|
112 |
timeout = 100
|
113 |
contact_support = """
|
|
|
472 |
|
473 |
@app.post("/Bing/Dall-E-3")
|
474 |
async def bing_dalle(item: BingDalle):
|
475 |
+
BingImages = await BingImage(image_provider=BingCreateImages)
|
476 |
+
try:
|
477 |
set_cookies(
|
478 |
".bing.com",
|
479 |
{
|
|
|
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 |
except BaseException as e:
|
493 |
return {"status": "false", "message": f"Internal Error: {e}"}
|
|
|
|
|
|
|
494 |
return response
|
495 |
+
try:
|
496 |
+
response = await generate_image(item.prompt, item.model)
|
497 |
+
image_url = response.data[0].url
|
498 |
+
return {"status": "true", "sukuna": {"message": image_url}}
|
499 |
except BaseException as e:
|
500 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|
501 |
|