Spaces:
Running
Running
SoulofSukuna
commited on
Commit
·
a23a1ef
1
Parent(s):
db93e80
g-ai
Browse files
main.py
CHANGED
@@ -73,18 +73,25 @@ logging.basicConfig(level=logging.ERROR)
|
|
73 |
|
74 |
# I DON'T KNOW LIKE THIS HACKER
|
75 |
load_dotenv()
|
76 |
-
REVERSE_IMAGE_API = os.environ["REVERSE_IMAGE_API"]
|
77 |
-
OCR_API_KEY = os.environ["OCR_API_KEY"]
|
78 |
-
ONLY_DEVELOPER_API_KEYS = os.environ["ONLY_DEVELOPER_API_KEYS"]
|
79 |
-
HUGGING_TOKEN = os.environ["HUGGING_TOKEN"]
|
80 |
SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
|
81 |
SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
|
82 |
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
|
83 |
SOURCE_WAIFU_URL = "https://api.waifu.pics"
|
84 |
SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
|
85 |
SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
|
|
|
|
|
|
|
86 |
DEVELOPER_ID = os.environ["DEVELOPER_ID"]
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
description = """
|
89 |
~ Developed written and powered by
|
90 |
- Ryuzaki Library: [Library Here](https://github.com/TeamKillerX/RyuzakiLib)
|
@@ -112,6 +119,15 @@ def validate_api_key_only_devs(api_key: str = Header(...)):
|
|
112 |
raise HTTPException(status_code=401, detail="Invalid API key")
|
113 |
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
@app.get("/UFoP/getbanlist")
|
116 |
def sibyl_get_all_banlist():
|
117 |
banned_users = db.get_all_banned()
|
@@ -122,15 +138,6 @@ def sibyl_get_all_banlist():
|
|
122 |
}
|
123 |
}
|
124 |
|
125 |
-
@app.get("/UFoP/blacklist-words")
|
126 |
-
def blacklist_words():
|
127 |
-
try:
|
128 |
-
BLACKLIST_WORDS = BadWordsList()
|
129 |
-
results_all = BLACKLIST_WORDS.banned_by_google(file_txt="banned_by_google.txt", storage=True)
|
130 |
-
return {"status": "true", "results": results_all}
|
131 |
-
except Exception as e:
|
132 |
-
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
133 |
-
|
134 |
@app.delete("/UFoP/bandel", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
135 |
def sibyl_system_delete(
|
136 |
item: SibylSystemDel,
|
@@ -207,29 +214,34 @@ def sibyl_system(
|
|
207 |
else:
|
208 |
return {"status": "false", "message": "Not Found User"}
|
209 |
|
210 |
-
@app.
|
211 |
-
def
|
212 |
-
|
213 |
-
api_key: None = Depends(
|
214 |
):
|
|
|
|
|
|
|
215 |
try:
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
|
|
233 |
|
234 |
@app.get("/ryuzaki/unsplash")
|
235 |
async def get_image_unsplash(query: str, size: str="500x500"):
|
|
|
73 |
|
74 |
# I DON'T KNOW LIKE THIS HACKER
|
75 |
load_dotenv()
|
|
|
|
|
|
|
|
|
76 |
SOURCE_UNSPLASH_URL = os.environ["SOURCE_UNSPLASH_URL"]
|
77 |
SOURCE_OCR_URL = os.environ["SOURCE_OCR_URL"]
|
78 |
SOURCE_ALPHA_URL = os.environ["SOURCE_ALPHA_URL"]
|
79 |
SOURCE_WAIFU_URL = "https://api.waifu.pics"
|
80 |
SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
|
81 |
SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
|
82 |
+
SOURCE_ASSISTANT_GOOGLE_AI = os.environ["SOURCE_ASSISTANT_GOOGLE_AI"]
|
83 |
+
SOURCE_OPENDALLE_URL = os.environ["SOURCE_OPENDALLE_URL"]
|
84 |
+
SOURCE_OPENAI_ACCESS_URL = os.environ["SOURCE_OPENAI_ACCESS_URL"]
|
85 |
DEVELOPER_ID = os.environ["DEVELOPER_ID"]
|
86 |
|
87 |
+
# api keys
|
88 |
+
REVERSE_IMAGE_API = os.environ["REVERSE_IMAGE_API"]
|
89 |
+
OCR_API_KEY = os.environ["OCR_API_KEY"]
|
90 |
+
ONLY_DEVELOPER_API_KEYS = os.environ["ONLY_DEVELOPER_API_KEYS"]
|
91 |
+
HUGGING_TOKEN = os.environ["HUGGING_TOKEN"]
|
92 |
+
ASSISTANT_GOOGLE_API_KEYS = os.environ["ASSISTANT_GOOGLE_API_KEYS"]
|
93 |
+
#COOKIE_BARD_TOKEN = os.environ["COOKIE_BARD_TOKEN"]
|
94 |
+
|
95 |
description = """
|
96 |
~ Developed written and powered by
|
97 |
- Ryuzaki Library: [Library Here](https://github.com/TeamKillerX/RyuzakiLib)
|
|
|
119 |
raise HTTPException(status_code=401, detail="Invalid API key")
|
120 |
|
121 |
|
122 |
+
@app.get("/UFoP/blacklist-words")
|
123 |
+
def blacklist_words():
|
124 |
+
try:
|
125 |
+
BLACKLIST_WORDS = BadWordsList()
|
126 |
+
results_all = BLACKLIST_WORDS.banned_by_google(file_txt="banned_by_google.txt", storage=True)
|
127 |
+
return {"status": "true", "results": results_all}
|
128 |
+
except Exception as e:
|
129 |
+
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
130 |
+
|
131 |
@app.get("/UFoP/getbanlist")
|
132 |
def sibyl_get_all_banlist():
|
133 |
banned_users = db.get_all_banned()
|
|
|
138 |
}
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
@app.delete("/UFoP/bandel", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
142 |
def sibyl_system_delete(
|
143 |
item: SibylSystemDel,
|
|
|
214 |
else:
|
215 |
return {"status": "false", "message": "Not Found User"}
|
216 |
|
217 |
+
@app.post("/UFoP/G-AI", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
218 |
+
def v1beta3_google_ai(
|
219 |
+
item: ChatgptCustom,
|
220 |
+
api_key: None = Depends(validate_api_key)
|
221 |
):
|
222 |
+
url = SOURCE_ASSISTANT_GOOGLE_AI
|
223 |
+
token = ASSISTANT_GOOGLE_API_KEYS
|
224 |
+
api_url = f"{SOURCE_ASSISTANT_GOOGLE_AI}/models/text-bison-001:generateText?key={ASSISTANT_GOOGLE_API_KEYS}"
|
225 |
try:
|
226 |
+
headers = {"Content-Type": "application/json"}
|
227 |
+
data = {
|
228 |
+
"prompt": {
|
229 |
+
"text": item.query
|
230 |
+
}
|
231 |
+
}
|
232 |
+
response = requests.post(api_url, headers=headers, json=data)
|
233 |
+
response_str = response.json()
|
234 |
+
answer = response_str["candidates"]
|
235 |
+
for results in answer:
|
236 |
+
message = results.get("output")
|
237 |
+
return SuccessResponse(
|
238 |
+
status="True",
|
239 |
+
randydev={
|
240 |
+
"message": message
|
241 |
+
}
|
242 |
+
)
|
243 |
+
except:
|
244 |
+
return {"status": "false", "message": "Error response."}
|
245 |
|
246 |
@app.get("/ryuzaki/unsplash")
|
247 |
async def get_image_unsplash(query: str, size: str="500x500"):
|