Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -124,7 +124,14 @@ contact_support = """
|
|
124 |
We are aware that AI is currently offline. This seems to be caused by the API
|
125 |
We are investigating and doing our best to get things back online as soon as possible. Thank you for your patience
|
126 |
|
127 |
-
Contact Support @xtdevs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
"""
|
129 |
|
130 |
def get_all_api_keys():
|
@@ -548,7 +555,7 @@ def dalle_3xl(
|
|
548 |
except requests.exceptions.RequestException:
|
549 |
raise HTTPException(
|
550 |
status_code=500,
|
551 |
-
detail=CustomErrorResponseModel(detail=[{}])
|
552 |
)
|
553 |
|
554 |
try:
|
@@ -556,7 +563,7 @@ def dalle_3xl(
|
|
556 |
except Exception:
|
557 |
raise HTTPException(
|
558 |
status_code=500,
|
559 |
-
detail=CustomErrorResponseModel(detail=[{}])
|
560 |
)
|
561 |
|
562 |
if encoded_string:
|
@@ -578,14 +585,14 @@ def open_dalle(
|
|
578 |
except requests.exceptions.RequestException:
|
579 |
raise HTTPException(
|
580 |
status_code=500,
|
581 |
-
detail=CustomErrorResponseModel(detail=[{}])
|
582 |
)
|
583 |
try:
|
584 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
585 |
except Exception:
|
586 |
raise HTTPException(
|
587 |
status_code=500,
|
588 |
-
detail=CustomErrorResponseModel(detail=[{}])
|
589 |
)
|
590 |
if encoded_string:
|
591 |
return SuccessResponse(status="True", randydev={"data": encoded_string})
|
@@ -788,7 +795,7 @@ def v1beta3_google_ai(
|
|
788 |
message = results.get("output")
|
789 |
return SuccessResponse(status="True", randydev={"message": message})
|
790 |
except:
|
791 |
-
return SuccessResponse(status="False", randydev={"message":
|
792 |
|
793 |
@app.post("/ryuzaki/gemini-ai-pro", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
794 |
def gemini_pro(item: GeminiPro):
|
@@ -1369,6 +1376,17 @@ description = """
|
|
1369 |
|
1370 |
•Developed by [@xtdevs](https://t.me/xtdevs)
|
1371 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1372 |
def custom_openapi():
|
1373 |
if app.openapi_schema:
|
1374 |
return app.openapi_schema
|
@@ -1386,3 +1404,5 @@ def custom_openapi():
|
|
1386 |
return app.openapi_schema
|
1387 |
|
1388 |
app.openapi = custom_openapi
|
|
|
|
|
|
124 |
We are aware that AI is currently offline. This seems to be caused by the API
|
125 |
We are investigating and doing our best to get things back online as soon as possible. Thank you for your patience
|
126 |
|
127 |
+
~ Contact Support @xtdevs
|
128 |
+
"""
|
129 |
+
|
130 |
+
internal_error = """
|
131 |
+
There has been an Internal error. We are aware of this error and notice that it can be
|
132 |
+
caused by your search terms being to explict, too confusing, or it can be caused by the API.
|
133 |
+
Please modify your search terms and/or try again later thank you for your understanding.
|
134 |
+
~ @xtdevs
|
135 |
"""
|
136 |
|
137 |
def get_all_api_keys():
|
|
|
555 |
except requests.exceptions.RequestException:
|
556 |
raise HTTPException(
|
557 |
status_code=500,
|
558 |
+
detail=CustomErrorResponseModel(detail=[{"Error": internal_error}])
|
559 |
)
|
560 |
|
561 |
try:
|
|
|
563 |
except Exception:
|
564 |
raise HTTPException(
|
565 |
status_code=500,
|
566 |
+
detail=CustomErrorResponseModel(detail=[{"Error": contact_support}])
|
567 |
)
|
568 |
|
569 |
if encoded_string:
|
|
|
585 |
except requests.exceptions.RequestException:
|
586 |
raise HTTPException(
|
587 |
status_code=500,
|
588 |
+
detail=CustomErrorResponseModel(detail=[{"Error": internal_error}])
|
589 |
)
|
590 |
try:
|
591 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
592 |
except Exception:
|
593 |
raise HTTPException(
|
594 |
status_code=500,
|
595 |
+
detail=CustomErrorResponseModel(detail=[{"Error": contact_support}])
|
596 |
)
|
597 |
if encoded_string:
|
598 |
return SuccessResponse(status="True", randydev={"data": encoded_string})
|
|
|
795 |
message = results.get("output")
|
796 |
return SuccessResponse(status="True", randydev={"message": message})
|
797 |
except:
|
798 |
+
return SuccessResponse(status="False", randydev={"message": internal_error})
|
799 |
|
800 |
@app.post("/ryuzaki/gemini-ai-pro", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
801 |
def gemini_pro(item: GeminiPro):
|
|
|
1376 |
|
1377 |
•Developed by [@xtdevs](https://t.me/xtdevs)
|
1378 |
"""
|
1379 |
+
|
1380 |
+
def custom_exception_handler(request: Request, exc: HTTPException) -> JSONResponse:
|
1381 |
+
error_detail = [{"error": str(exc.detail)}]
|
1382 |
+
custom_error_model = CustomErrorResponseModel(detail=error_detail)
|
1383 |
+
|
1384 |
+
return JSONResponse(
|
1385 |
+
status_code=exc.status_code,
|
1386 |
+
content=custom_error_model.dict(),
|
1387 |
+
headers=exc.headers,
|
1388 |
+
)
|
1389 |
+
|
1390 |
def custom_openapi():
|
1391 |
if app.openapi_schema:
|
1392 |
return app.openapi_schema
|
|
|
1404 |
return app.openapi_schema
|
1405 |
|
1406 |
app.openapi = custom_openapi
|
1407 |
+
|
1408 |
+
app.add_exception_handler(HTTPException, custom_exception_handler)
|