Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -497,7 +497,10 @@ def bing_dalle(item: BingDalle):
|
|
497 |
|
498 |
|
499 |
@app.post("/UFoP/dalle3xl")
|
500 |
-
def dalle_3xl(
|
|
|
|
|
|
|
501 |
API_URL = SOURCE_DALLE3XL_URL
|
502 |
try:
|
503 |
payload = {"inputs": item.query}
|
@@ -505,17 +508,21 @@ def dalle_3xl(item: Dalle3XL, api_key: None = Depends(validate_api_key)):
|
|
505 |
"Authorization": f"Bearer {HUGGING_TOKEN}",
|
506 |
"Content-Type": "application/json",
|
507 |
}
|
508 |
-
response = requests.post(
|
509 |
-
API_URL, headers=headers, json=payload, timeout=timeout
|
510 |
-
)
|
511 |
response.raise_for_status()
|
512 |
except requests.exceptions.RequestException:
|
513 |
-
raise HTTPException(
|
|
|
|
|
|
|
514 |
|
515 |
try:
|
516 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
517 |
except Exception:
|
518 |
-
raise HTTPException(
|
|
|
|
|
|
|
519 |
|
520 |
if encoded_string:
|
521 |
return SuccessResponse(status="True", randydev={"data": encoded_string})
|
@@ -524,7 +531,10 @@ def dalle_3xl(item: Dalle3XL, api_key: None = Depends(validate_api_key)):
|
|
524 |
|
525 |
|
526 |
@app.post("/UFoP/proteusv02")
|
527 |
-
async def proteusv0_2(
|
|
|
|
|
|
|
528 |
API_URL = SOURCE_PROTEUSV0_2_URL
|
529 |
try:
|
530 |
payload = {"inputs": item.query}
|
@@ -538,12 +548,18 @@ async def proteusv0_2(item: ProteusV02, api_key: None = Depends(validate_api_key
|
|
538 |
)
|
539 |
response.raise_for_status()
|
540 |
except httpx.HTTPStatusError:
|
541 |
-
raise HTTPException(
|
|
|
|
|
|
|
542 |
|
543 |
try:
|
544 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
545 |
except Exception:
|
546 |
-
raise HTTPException(
|
|
|
|
|
|
|
547 |
|
548 |
if encoded_string:
|
549 |
return SuccessResponse(status="True", randydev={"data": encoded_string})
|
|
|
497 |
|
498 |
|
499 |
@app.post("/UFoP/dalle3xl")
|
500 |
+
def dalle_3xl(
|
501 |
+
item: Dalle3XL,
|
502 |
+
api_key: None = Depends(validate_api_key)
|
503 |
+
):
|
504 |
API_URL = SOURCE_DALLE3XL_URL
|
505 |
try:
|
506 |
payload = {"inputs": item.query}
|
|
|
508 |
"Authorization": f"Bearer {HUGGING_TOKEN}",
|
509 |
"Content-Type": "application/json",
|
510 |
}
|
511 |
+
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
|
|
|
|
512 |
response.raise_for_status()
|
513 |
except requests.exceptions.RequestException:
|
514 |
+
raise HTTPException(
|
515 |
+
status_code=500,
|
516 |
+
detail=internal_error
|
517 |
+
)
|
518 |
|
519 |
try:
|
520 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
521 |
except Exception:
|
522 |
+
raise HTTPException(
|
523 |
+
status_code=500,
|
524 |
+
detail=contact_support
|
525 |
+
)
|
526 |
|
527 |
if encoded_string:
|
528 |
return SuccessResponse(status="True", randydev={"data": encoded_string})
|
|
|
531 |
|
532 |
|
533 |
@app.post("/UFoP/proteusv02")
|
534 |
+
async def proteusv0_2(
|
535 |
+
item: ProteusV02,
|
536 |
+
api_key: None = Depends(validate_api_key)
|
537 |
+
):
|
538 |
API_URL = SOURCE_PROTEUSV0_2_URL
|
539 |
try:
|
540 |
payload = {"inputs": item.query}
|
|
|
548 |
)
|
549 |
response.raise_for_status()
|
550 |
except httpx.HTTPStatusError:
|
551 |
+
raise HTTPException(
|
552 |
+
status_code=500,
|
553 |
+
detail=internal_error
|
554 |
+
)
|
555 |
|
556 |
try:
|
557 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
558 |
except Exception:
|
559 |
+
raise HTTPException(
|
560 |
+
status_code=500,
|
561 |
+
detail=contact_support
|
562 |
+
)
|
563 |
|
564 |
if encoded_string:
|
565 |
return SuccessResponse(status="True", randydev={"data": encoded_string})
|