Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -269,6 +269,20 @@ class GeminiPro(BaseModel):
|
|
269 |
bard_api_key: Optional[str] = None
|
270 |
is_login: bool=False
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
@app.post("/ryuzaki/profile-clone", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
273 |
def profile_clone(
|
274 |
item: ProfileClone,
|
@@ -845,9 +859,9 @@ def chatbot(
|
|
845 |
return {"status": "false", "message": "Error response."}
|
846 |
|
847 |
@app.get("/ryuzaki/llama")
|
848 |
-
def get_llama(
|
849 |
api_url = SOURCE_WHAT_GAY_URL
|
850 |
-
params = {"query": query}
|
851 |
x = requests.get(f"{api_url}/llama", params=params)
|
852 |
if x.status_code != 200:
|
853 |
return "Error api request"
|
@@ -864,14 +878,9 @@ def get_llama(query: str):
|
|
864 |
return {"status": "false", "message": "Error response."}
|
865 |
|
866 |
@app.get("/ryuzaki/waifu")
|
867 |
-
def waifu_pics(
|
868 |
-
|
869 |
-
|
870 |
-
media_type: str=None,
|
871 |
-
is_bytes: bool=False
|
872 |
-
):
|
873 |
-
waifu_api = f"{SOURCE_WAIFU_URL}/{types}"
|
874 |
-
waifu_param = f"{waifu_api}/{category}"
|
875 |
|
876 |
response = requests.get(waifu_param)
|
877 |
|
@@ -883,13 +892,13 @@ def waifu_pics(
|
|
883 |
except Exception as e:
|
884 |
return f"Error request {e}"
|
885 |
if waifu_image_url:
|
886 |
-
if is_bytes:
|
887 |
try:
|
888 |
response_two = requests.get(waifu_image_url)
|
889 |
response_two.raise_for_status()
|
890 |
except requests.exceptions.RequestException:
|
891 |
raise HTTPException(status_code=500, detail="Internal server error")
|
892 |
-
return StreamingResponse(BytesIO(response_two.content), media_type=media_type)
|
893 |
else:
|
894 |
return {
|
895 |
"status": "true",
|
@@ -901,29 +910,22 @@ def waifu_pics(
|
|
901 |
return {"status": "false", "message": "Error response."}
|
902 |
|
903 |
@app.get("/ryuzaki/rayso")
|
904 |
-
def make_rayso(
|
905 |
-
code=None,
|
906 |
-
title: str="Ryuzaki Dev",
|
907 |
-
theme: str=None,
|
908 |
-
setlang: str="en",
|
909 |
-
auto_translate: bool=None,
|
910 |
-
ryuzaki_dark: bool=None
|
911 |
-
):
|
912 |
trans = SyncTranslator()
|
913 |
api_url = b64decode("aHR0cHM6Ly9hcGkuc2Fmb25lLm1lL3JheXNv").decode("utf-8")
|
914 |
-
if auto_translate:
|
915 |
-
source = trans.detect(code)
|
916 |
-
translation = trans(code, sourcelang=source, targetlang=setlang)
|
917 |
code = translation.text
|
918 |
else:
|
919 |
-
code = code
|
920 |
-
if ryuzaki_dark:
|
921 |
x = requests.post(
|
922 |
f"{api_url}",
|
923 |
json={
|
924 |
"code": code,
|
925 |
-
"title": title,
|
926 |
-
"theme": theme,
|
927 |
"darkMode": True
|
928 |
}
|
929 |
)
|
@@ -945,8 +947,8 @@ def make_rayso(
|
|
945 |
f"{api_url}",
|
946 |
json={
|
947 |
"code": code,
|
948 |
-
"title": title,
|
949 |
-
"theme": theme,
|
950 |
"darkMode": False
|
951 |
}
|
952 |
)
|
|
|
269 |
bard_api_key: Optional[str] = None
|
270 |
is_login: bool=False
|
271 |
|
272 |
+
class WaifuPics(BaseModel):
|
273 |
+
types: str="sfw"
|
274 |
+
category: str="neko"
|
275 |
+
media_type: Optional[str] = None
|
276 |
+
is_bytes: bool=False
|
277 |
+
|
278 |
+
class MakeRayso(BaseModel):
|
279 |
+
code: str
|
280 |
+
title: str="Ryuzaki Dev"
|
281 |
+
theme: str
|
282 |
+
setlang: str="en"
|
283 |
+
auto_translate: Optional[bool] = None
|
284 |
+
ryuzaki_dark: bool=True
|
285 |
+
|
286 |
@app.post("/ryuzaki/profile-clone", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
287 |
def profile_clone(
|
288 |
item: ProfileClone,
|
|
|
859 |
return {"status": "false", "message": "Error response."}
|
860 |
|
861 |
@app.get("/ryuzaki/llama")
|
862 |
+
def get_llama(item: ChatgptCustom):
|
863 |
api_url = SOURCE_WHAT_GAY_URL
|
864 |
+
params = {"query": item.query}
|
865 |
x = requests.get(f"{api_url}/llama", params=params)
|
866 |
if x.status_code != 200:
|
867 |
return "Error api request"
|
|
|
878 |
return {"status": "false", "message": "Error response."}
|
879 |
|
880 |
@app.get("/ryuzaki/waifu")
|
881 |
+
def waifu_pics(item: WaifuPics):
|
882 |
+
waifu_api = f"{SOURCE_WAIFU_URL}/{item.types}"
|
883 |
+
waifu_param = f"{waifu_api}/{item.category}"
|
|
|
|
|
|
|
|
|
|
|
884 |
|
885 |
response = requests.get(waifu_param)
|
886 |
|
|
|
892 |
except Exception as e:
|
893 |
return f"Error request {e}"
|
894 |
if waifu_image_url:
|
895 |
+
if item.is_bytes:
|
896 |
try:
|
897 |
response_two = requests.get(waifu_image_url)
|
898 |
response_two.raise_for_status()
|
899 |
except requests.exceptions.RequestException:
|
900 |
raise HTTPException(status_code=500, detail="Internal server error")
|
901 |
+
return StreamingResponse(BytesIO(response_two.content), media_type=item.media_type)
|
902 |
else:
|
903 |
return {
|
904 |
"status": "true",
|
|
|
910 |
return {"status": "false", "message": "Error response."}
|
911 |
|
912 |
@app.get("/ryuzaki/rayso")
|
913 |
+
def make_rayso(item: MakeRayso):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
914 |
trans = SyncTranslator()
|
915 |
api_url = b64decode("aHR0cHM6Ly9hcGkuc2Fmb25lLm1lL3JheXNv").decode("utf-8")
|
916 |
+
if item.auto_translate:
|
917 |
+
source = trans.detect(item.code)
|
918 |
+
translation = trans(item.code, sourcelang=source, targetlang=item.setlang)
|
919 |
code = translation.text
|
920 |
else:
|
921 |
+
code = item.code
|
922 |
+
if item.ryuzaki_dark:
|
923 |
x = requests.post(
|
924 |
f"{api_url}",
|
925 |
json={
|
926 |
"code": code,
|
927 |
+
"title": item.title,
|
928 |
+
"theme": item.theme,
|
929 |
"darkMode": True
|
930 |
}
|
931 |
)
|
|
|
947 |
f"{api_url}",
|
948 |
json={
|
949 |
"code": code,
|
950 |
+
"title": item.title,
|
951 |
+
"theme": item.theme,
|
952 |
"darkMode": False
|
953 |
}
|
954 |
)
|