Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -805,7 +805,8 @@ def get_llama(query: str):
|
|
805 |
def waifu_pics(
|
806 |
types: str="sfw",
|
807 |
category: str="neko",
|
808 |
-
media_type: str=None
|
|
|
809 |
):
|
810 |
waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
|
811 |
waifu_param = f"{waifu_api}/{category}"
|
@@ -820,12 +821,20 @@ def waifu_pics(
|
|
820 |
except Exception as e:
|
821 |
return f"Error request {e}"
|
822 |
if waifu_image_url:
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
829 |
else:
|
830 |
return {"status": "false", "message": "Error response."}
|
831 |
|
|
|
805 |
def waifu_pics(
|
806 |
types: str="sfw",
|
807 |
category: str="neko",
|
808 |
+
media_type: str=None,
|
809 |
+
is_bytes: bool=False
|
810 |
):
|
811 |
waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
|
812 |
waifu_param = f"{waifu_api}/{category}"
|
|
|
821 |
except Exception as e:
|
822 |
return f"Error request {e}"
|
823 |
if waifu_image_url:
|
824 |
+
if is_bytes:
|
825 |
+
try:
|
826 |
+
response_two = requests.get(waifu_image_url)
|
827 |
+
response_two.raise_for_status()
|
828 |
+
except requests.exceptions.RequestException:
|
829 |
+
raise HTTPException(status_code=500, detail="Internal server error")
|
830 |
+
return StreamingResponse(BytesIO(response_two.content), media_type=media_type)
|
831 |
+
else:
|
832 |
+
return {
|
833 |
+
"status": "true",
|
834 |
+
"randydev":{
|
835 |
+
"image_url": waifu_image_url
|
836 |
+
}
|
837 |
+
}
|
838 |
else:
|
839 |
return {"status": "false", "message": "Error response."}
|
840 |
|