Spaces:
Running
Running
Upload 2 files
Browse files
main.py
CHANGED
@@ -85,6 +85,7 @@ MONGO_URL = os.environ["MONGO_URL"]
|
|
85 |
SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
|
86 |
SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
|
87 |
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
|
|
|
88 |
SOURCE_WAIFU_URL = os.environ["SOURCE_WAIFU_URL"]
|
89 |
SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
|
90 |
SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
|
@@ -387,6 +388,36 @@ def ryuzaki_ai(
|
|
387 |
except Exception:
|
388 |
return {"status": "false", "message": "Internal server error"}
|
389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
@app.get("/ryuzaki/unsplash")
|
391 |
async def get_image_unsplash(item: GetImageUnsplash):
|
392 |
url = SOURCE_UNSPLASH_URL
|
|
|
85 |
SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
|
86 |
SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
|
87 |
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
|
88 |
+
SOURCE_OPENDALLE_URL = os.environ["SOURCE_OPENDALLE_URL"]
|
89 |
SOURCE_WAIFU_URL = os.environ["SOURCE_WAIFU_URL"]
|
90 |
SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
|
91 |
SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
|
|
|
388 |
except Exception:
|
389 |
return {"status": "false", "message": "Internal server error"}
|
390 |
|
391 |
+
@app.post("/ryuzaki/opendalle")
|
392 |
+
async def open_dalle(
|
393 |
+
item: OpenDalle,
|
394 |
+
api_key: None = Depends(validate_api_key)
|
395 |
+
):
|
396 |
+
API_URL = SOURCE_OPENDALLE_URL
|
397 |
+
try:
|
398 |
+
payload = {"inputs": item.query}
|
399 |
+
headers = {"Authorization": f"Bearer {HUGGING_TOKEN}"}
|
400 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
401 |
+
response.raise_for_status()
|
402 |
+
except requests.exceptions.RequestException:
|
403 |
+
raise HTTPException(
|
404 |
+
status_code=500,
|
405 |
+
detail=CustomErrorResponseModel(detail=[{}])
|
406 |
+
)
|
407 |
+
try:
|
408 |
+
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
409 |
+
except Exception:
|
410 |
+
raise HTTPException(
|
411 |
+
status_code=500,
|
412 |
+
detail=CustomErrorResponseModel(detail=[{}])
|
413 |
+
)
|
414 |
+
headers = {"Content-Type": "image/jpeg"}
|
415 |
+
return Response(
|
416 |
+
content=encoded_string,
|
417 |
+
media_type="image/jpeg",
|
418 |
+
headers=headers
|
419 |
+
)
|
420 |
+
|
421 |
@app.get("/ryuzaki/unsplash")
|
422 |
async def get_image_unsplash(item: GetImageUnsplash):
|
423 |
url = SOURCE_UNSPLASH_URL
|
models.py
CHANGED
@@ -121,3 +121,6 @@ class GetMonitorLogs(BaseModel):
|
|
121 |
|
122 |
class DownloadLink(BaseModel):
|
123 |
link: str
|
|
|
|
|
|
|
|
121 |
|
122 |
class DownloadLink(BaseModel):
|
123 |
link: str
|
124 |
+
|
125 |
+
class OpenDalle(BaseModel):
|
126 |
+
query: str
|