Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -89,6 +89,7 @@ SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
|
|
89 |
SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
|
90 |
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
|
91 |
SOURCE_OPENDALLE_URL = os.environ["SOURCE_OPENDALLE_URL"]
|
|
|
92 |
SOURCE_ANIME_STYLED_URL = os.environ["SOURCE_ANIME_STYLED_URL"]
|
93 |
SOURCE_WAIFU_URL = os.environ["SOURCE_WAIFU_URL"]
|
94 |
SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
|
@@ -117,6 +118,8 @@ trans = SyncTranslator()
|
|
117 |
|
118 |
app = FastAPI(docs_url=None, redoc_url="/")
|
119 |
|
|
|
|
|
120 |
contact_support = """
|
121 |
We are aware that AI is currently offline. This seems to be caused by the API
|
122 |
We are investigating and doing our best to get things back online as soon as possible. Thank you for your patience
|
@@ -528,6 +531,39 @@ def ryuzaki_ai(
|
|
528 |
except Exception:
|
529 |
return SuccessResponse(status="False", randydev={"message": contact_support})
|
530 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
@app.post("/ryuzaki/opendalle")
|
532 |
def open_dalle(
|
533 |
item: OpenDalle,
|
|
|
89 |
SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
|
90 |
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
|
91 |
SOURCE_OPENDALLE_URL = os.environ["SOURCE_OPENDALLE_URL"]
|
92 |
+
SOURCE_DALLE3XL_URL = os.environ["SOURCE_DALLE3XL_URL"]
|
93 |
SOURCE_ANIME_STYLED_URL = os.environ["SOURCE_ANIME_STYLED_URL"]
|
94 |
SOURCE_WAIFU_URL = os.environ["SOURCE_WAIFU_URL"]
|
95 |
SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
|
|
|
118 |
|
119 |
app = FastAPI(docs_url=None, redoc_url="/")
|
120 |
|
121 |
+
timeout = 100
|
122 |
+
|
123 |
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
|
|
|
531 |
except Exception:
|
532 |
return SuccessResponse(status="False", randydev={"message": contact_support})
|
533 |
|
534 |
+
@app.post("/ryuzaki/dalle3xl")
|
535 |
+
def dalle_3xl(
|
536 |
+
item: Dalle3XL,
|
537 |
+
api_key: None = Depends(validate_api_key)
|
538 |
+
):
|
539 |
+
API_URL = SOURCE_DALLE3XL_URL
|
540 |
+
try:
|
541 |
+
payload = {"inputs": item.query}
|
542 |
+
headers = {
|
543 |
+
"Authorization": f"Bearer {HUGGING_TOKEN}",
|
544 |
+
"Content-Type": "application/json",
|
545 |
+
}
|
546 |
+
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
547 |
+
response.raise_for_status()
|
548 |
+
except requests.exceptions.RequestException:
|
549 |
+
raise HTTPException(
|
550 |
+
status_code=500,
|
551 |
+
detail=CustomErrorResponseModel(detail=[{}])
|
552 |
+
)
|
553 |
+
|
554 |
+
try:
|
555 |
+
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
556 |
+
except Exception:
|
557 |
+
raise HTTPException(
|
558 |
+
status_code=500,
|
559 |
+
detail=CustomErrorResponseModel(detail=[{}])
|
560 |
+
)
|
561 |
+
|
562 |
+
if encoded_string:
|
563 |
+
return SuccessResponse(status="True", randydev={"data": encoded_string})
|
564 |
+
else:
|
565 |
+
return SuccessResponse(status="False", randydev={"data": contact_support})
|
566 |
+
|
567 |
@app.post("/ryuzaki/opendalle")
|
568 |
def open_dalle(
|
569 |
item: OpenDalle,
|