Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
@@ -107,6 +107,7 @@ app = FastAPI(
|
|
107 |
)
|
108 |
|
109 |
trans = SyncTranslator()
|
|
|
110 |
|
111 |
timeout = 100
|
112 |
contact_support = """
|
@@ -471,7 +472,6 @@ def gemini_pro(item: GeminiPro):
|
|
471 |
|
472 |
@app.post("/Bing/Dall-E-3")
|
473 |
async def bing_dalle(item: BingDalle):
|
474 |
-
BingImages = BingClient()
|
475 |
try:
|
476 |
set_cookies(
|
477 |
".bing.com",
|
@@ -482,11 +482,11 @@ 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 BingCreateImages.create_async(
|
488 |
-
prompt=prompt,
|
489 |
model=model,
|
|
|
490 |
)
|
491 |
|
492 |
image_url = response.get('data', [])[0].get('url')
|
@@ -497,7 +497,7 @@ async def bing_dalle(item: BingDalle):
|
|
497 |
return {"status": "false", "message": f"Internal Error: {e}"}
|
498 |
|
499 |
try:
|
500 |
-
response = await generate_image(item.
|
501 |
return response
|
502 |
except BaseException as e:
|
503 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|
|
|
107 |
)
|
108 |
|
109 |
trans = SyncTranslator()
|
110 |
+
BingImages = BingClient()
|
111 |
|
112 |
timeout = 100
|
113 |
contact_support = """
|
|
|
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 |
+
async def generate_image(model, prompt):
|
486 |
try:
|
487 |
response = await BingCreateImages.create_async(
|
|
|
488 |
model=model,
|
489 |
+
prompt=prompt,
|
490 |
)
|
491 |
|
492 |
image_url = response.get('data', [])[0].get('url')
|
|
|
497 |
return {"status": "false", "message": f"Internal Error: {e}"}
|
498 |
|
499 |
try:
|
500 |
+
response = await generate_image(item.model, item.prompt)
|
501 |
return response
|
502 |
except BaseException as e:
|
503 |
return {"status": "false", "message": f"Something went wrong: {e}"}
|