Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -35,6 +35,7 @@ from bs4 import BeautifulSoup
|
|
35 |
from typing import Union
|
36 |
from typing_extensions import Annotated
|
37 |
from typing import Annotated, Union
|
|
|
38 |
|
39 |
from pydantic import BaseModel
|
40 |
from base64 import b64decode as kc
|
@@ -201,45 +202,63 @@ def get_profile_clone(user_id):
|
|
201 |
else:
|
202 |
return None
|
203 |
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
def profile_clone(
|
206 |
-
|
207 |
-
first_name=None,
|
208 |
-
last_name=None,
|
209 |
-
profile_id=None,
|
210 |
-
bio=None,
|
211 |
api_key: None = Depends(validate_api_key)
|
212 |
):
|
213 |
-
if user_id == 1191668125:
|
214 |
return {"status": "false", "message": "Only Developer"}
|
|
|
215 |
try:
|
216 |
new_profile_clone(
|
217 |
-
user_id=user_id,
|
218 |
-
first_name=first_name,
|
219 |
-
last_name=last_name,
|
220 |
-
profile_id=profile_id,
|
221 |
-
bio=bio
|
222 |
)
|
223 |
return {
|
224 |
"status": "true",
|
225 |
"randydev": {
|
226 |
-
"user_id": user_id,
|
227 |
-
"first_name": first_name,
|
228 |
-
"last_name": last_name,
|
229 |
-
"profile_id": profile_id,
|
230 |
-
"bio": bio
|
231 |
}
|
232 |
}
|
233 |
except Exception as e:
|
234 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
235 |
|
236 |
-
|
|
|
|
|
|
|
237 |
def get_profile_(
|
238 |
-
|
239 |
api_key: None = Depends(validate_api_key)
|
240 |
):
|
241 |
try:
|
242 |
-
first_name, last_name, profile_id, bio = get_profile_clone(user_id)
|
243 |
if last_name is None:
|
244 |
last_name_str = ""
|
245 |
else:
|
@@ -252,7 +271,7 @@ def get_profile_(
|
|
252 |
return {
|
253 |
"status": "true",
|
254 |
"randydev": {
|
255 |
-
"user_id": user_id,
|
256 |
"first_name": first_name,
|
257 |
"last_name": last_name_str,
|
258 |
"profile_id": profile_id,
|
@@ -283,61 +302,70 @@ def blacklist_words():
|
|
283 |
except Exception as e:
|
284 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
285 |
|
286 |
-
|
|
|
|
|
|
|
287 |
def sibyl_system_delete(
|
288 |
-
|
289 |
api_key: None = Depends(validate_api_key_only_devs)
|
290 |
):
|
291 |
try:
|
292 |
-
_, _, _, _, sibyl_user_id = get_sibyl_system_banned(user_id)
|
293 |
|
294 |
if sibyl_user_id:
|
295 |
-
remove_sibyl_system_banned(user_id)
|
296 |
-
return {"status": "true", "message": f"Successfully removed {user_id} from the Sibyl ban list."}
|
297 |
else:
|
298 |
return {"status": "false", "message": "Not found user"}
|
299 |
except Exception as e:
|
300 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
301 |
|
302 |
-
|
|
|
|
|
|
|
|
|
303 |
def sibyl_system_ban(
|
304 |
-
|
305 |
-
reason: str = Query(..., description="Reason in query parameter"),
|
306 |
api_key: None = Depends(validate_api_key)
|
307 |
):
|
308 |
-
if user_id == 1191668125:
|
309 |
return {"status": "false", "message": "Only Developer"}
|
310 |
|
311 |
try:
|
312 |
date_joined = str(dt.now())
|
313 |
sibyl_ban = random.choice(RAMDOM_STATUS)
|
314 |
-
_, _, is_banned, _, sibyl_user_id = get_sibyl_system_banned(user_id)
|
315 |
|
316 |
if sibyl_user_id and is_banned:
|
317 |
return {"status": "false", "message": "User is already banned"}
|
318 |
|
319 |
-
new_sibyl_system_banned(user_id, sibyl_ban, reason, date_joined)
|
320 |
|
321 |
return {
|
322 |
"status": "true",
|
323 |
"randydev": {
|
324 |
-
"user_id": user_id,
|
325 |
"sibyl_name": sibyl_ban,
|
326 |
-
"reason": reason,
|
327 |
"date_joined": date_joined,
|
328 |
-
"message": f"Successfully banned {user_id} from the Sibyl ban list."
|
329 |
}
|
330 |
}
|
331 |
except Exception as e:
|
332 |
logging.error(f"Error in sibyl_system_ban: {e}")
|
333 |
return {"status": "false", "message": "Internal server error"}
|
334 |
|
335 |
-
|
|
|
|
|
|
|
336 |
def sibyl_system(
|
337 |
-
|
338 |
api_key: None = Depends(validate_api_key)
|
339 |
):
|
340 |
-
sibyl_name, reason, is_banned, date_joined, sibyl_user_id = get_sibyl_system_banned(user_id)
|
341 |
if sibyl_name and reason and is_banned and date_joined and sibyl_user_id:
|
342 |
return {
|
343 |
"status": "true",
|
@@ -352,13 +380,16 @@ def sibyl_system(
|
|
352 |
else:
|
353 |
return {"status": "false", "message": "Not Found User"}
|
354 |
|
355 |
-
|
|
|
|
|
|
|
356 |
def ryuzaki_ai(
|
357 |
-
|
358 |
api_key: None = Depends(validate_api_key)
|
359 |
):
|
360 |
try:
|
361 |
-
response_data = code.ryuzaki_ai_text(text)
|
362 |
|
363 |
if isinstance(response_data, list) and len(response_data) > 0:
|
364 |
first_result = response_data[0]
|
@@ -376,19 +407,29 @@ def ryuzaki_ai(
|
|
376 |
except Exception:
|
377 |
return {"status": "false", "message": "Internal server error"}
|
378 |
|
379 |
-
|
380 |
-
|
|
|
|
|
|
|
|
|
381 |
url = SOURCE_UNSPLASH_URL
|
382 |
-
image_url = f"{url}/?{query}/{size}"
|
383 |
try:
|
384 |
response = requests.get(image_url)
|
385 |
response.raise_for_status()
|
386 |
-
except requests.exceptions.RequestException
|
387 |
-
raise HTTPException(
|
|
|
|
|
|
|
388 |
try:
|
389 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
390 |
-
except Exception
|
391 |
-
raise HTTPException(
|
|
|
|
|
|
|
392 |
headers = {"Content-Type": "image/jpeg"}
|
393 |
return Response(
|
394 |
content=encoded_string,
|
@@ -396,33 +437,23 @@ async def get_image_unsplash(query: str, size: str = "500x500"):
|
|
396 |
headers=headers
|
397 |
)
|
398 |
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
try:
|
405 |
-
response = requests.get(image_url)
|
406 |
-
response.raise_for_status()
|
407 |
-
except requests.exceptions.RequestException:
|
408 |
-
raise HTTPException(status_code=500, detail="Internal server error")
|
409 |
-
|
410 |
-
return StreamingResponse(BytesIO(response.content), media_type="image/jpeg")
|
411 |
|
412 |
-
@app.get("/ryuzaki/reverse")
|
413 |
def google_reverse(
|
414 |
-
|
415 |
-
image_url: str=None,
|
416 |
-
language: str="en",
|
417 |
-
google_lang: str="us",
|
418 |
api_key: None = Depends(validate_api_key)
|
419 |
):
|
420 |
params = {
|
421 |
"api_key": REVERSE_IMAGE_API,
|
422 |
-
"engine": engine,
|
423 |
-
"image_url": image_url,
|
424 |
-
"hl": language,
|
425 |
-
"gl": google_lang
|
426 |
}
|
427 |
try:
|
428 |
search = GoogleSearch(params)
|
@@ -443,18 +474,21 @@ def google_reverse(
|
|
443 |
except Exception:
|
444 |
return {"status": "false", "message": "Internal server error"}
|
445 |
|
446 |
-
|
|
|
|
|
|
|
|
|
|
|
447 |
def ocr_space_url(
|
448 |
-
|
449 |
-
overlay: bool=False,
|
450 |
-
language: str = Query("eng", description="Language in query parameter"),
|
451 |
api_key: None = Depends(validate_api_key)
|
452 |
):
|
453 |
payload = {
|
454 |
-
"url": url,
|
455 |
-
"isOverlayRequired": overlay,
|
456 |
"apikey": OCR_API_KEY,
|
457 |
-
"language": language
|
458 |
}
|
459 |
try:
|
460 |
response = requests.post(SOURCE_OCR_URL, data=payload)
|
@@ -476,11 +510,16 @@ def ocr_space_url(
|
|
476 |
except (json.JSONDecodeError, KeyError):
|
477 |
return "Error parsing the OCR response."
|
478 |
|
479 |
-
|
480 |
-
|
|
|
|
|
|
|
|
|
|
|
481 |
url = "https://lexica.qewertyy.me/models"
|
482 |
-
if is_models:
|
483 |
-
params = {"model_id": model_id, "prompt": query}
|
484 |
response = requests.post(url, params=params)
|
485 |
if response.status_code != 200:
|
486 |
return f"Error status: {response.status_code}"
|
@@ -493,7 +532,7 @@ def chatgpt_model(query: str=None, model_id: int=None, is_models: bool=False):
|
|
493 |
}
|
494 |
}
|
495 |
else:
|
496 |
-
params = {"model_id": 5, "prompt": query}
|
497 |
response = requests.post(url, params=params)
|
498 |
if response.status_code != 200:
|
499 |
return f"Error status: {response.status_code}"
|
@@ -506,10 +545,13 @@ def chatgpt_model(query: str=None, model_id: int=None, is_models: bool=False):
|
|
506 |
}
|
507 |
}
|
508 |
|
509 |
-
|
510 |
-
|
|
|
|
|
|
|
511 |
try:
|
512 |
-
response = RendyDevChat(query).get_response_beta(joke=True)
|
513 |
return {
|
514 |
"status": "true",
|
515 |
"randydev":{
|
@@ -519,8 +561,8 @@ def free_chatgpt4_beta(query: str):
|
|
519 |
except:
|
520 |
return {"status": "false", "message": "Error response."}
|
521 |
|
522 |
-
@app.get("/ryuzaki/freechatgpt-bing")
|
523 |
-
def free_chatgpt4_bing(
|
524 |
try:
|
525 |
response = RendyDevChat(query).get_response_bing(bing=True)
|
526 |
return {
|
@@ -532,8 +574,11 @@ def free_chatgpt4_bing(query: str):
|
|
532 |
except:
|
533 |
return {"status": "false", "message": "Error response."}
|
534 |
|
535 |
-
@app.post("/ryuzaki/google-ai")
|
536 |
-
def v1beta3_google_ai(
|
|
|
|
|
|
|
537 |
url = SOURCE_ASSISTANT_GOOGLE_AI
|
538 |
token = ASSISTANT_GOOGLE_API_KEYS
|
539 |
api_url = f"{SOURCE_ASSISTANT_GOOGLE_AI}/v1beta3/models/text-bison-001:generateText?key={ASSISTANT_GOOGLE_API_KEYS}"
|
@@ -541,7 +586,7 @@ def v1beta3_google_ai(query: str, api_key: None = Depends(validate_api_key)):
|
|
541 |
headers = {"Content-Type": "application/json"}
|
542 |
data = {
|
543 |
"prompt": {
|
544 |
-
"text": query
|
545 |
}
|
546 |
}
|
547 |
response = requests.post(api_url, headers=headers, json=data)
|
@@ -558,15 +603,18 @@ def v1beta3_google_ai(query: str, api_key: None = Depends(validate_api_key)):
|
|
558 |
except:
|
559 |
return {"status": "false", "message": "Error response."}
|
560 |
|
561 |
-
|
|
|
|
|
|
|
|
|
|
|
562 |
def gemini_pro(
|
563 |
-
|
564 |
-
bard_api_key: str=None,
|
565 |
-
is_login: bool=False,
|
566 |
api_key: None = Depends(validate_api_key)
|
567 |
):
|
568 |
-
if is_login:
|
569 |
-
token = bard_api_key
|
570 |
else:
|
571 |
token = COOKIE_BARD_TOKEN
|
572 |
owner_base = f"""
|
@@ -588,7 +636,7 @@ def gemini_pro(
|
|
588 |
session.cookies.set("__Secure-1PSID", token)
|
589 |
bard = Bard(token=token, session=session, timeout=30)
|
590 |
bard.get_answer(owner_base)["content"]
|
591 |
-
message = bard.get_answer(query)["content"]
|
592 |
return {
|
593 |
"status": "true",
|
594 |
"randydev":{
|
@@ -600,7 +648,7 @@ def gemini_pro(
|
|
600 |
|
601 |
@app.post("/ryuzaki/v1beta2-google-ai")
|
602 |
def v1beta2_google_ai(
|
603 |
-
|
604 |
api_key: None = Depends(validate_api_key)
|
605 |
):
|
606 |
url = SOURCE_ASSISTANT_GOOGLE_AI
|
@@ -610,7 +658,7 @@ def v1beta2_google_ai(
|
|
610 |
headers = {"Content-Type": "application/json"}
|
611 |
data = {
|
612 |
"prompt": {
|
613 |
-
"messages": [{"content": query}]}
|
614 |
}
|
615 |
response = requests.post(api_url, headers=headers, json=data)
|
616 |
response_str = response.json()
|
@@ -1209,7 +1257,7 @@ def custom_openapi():
|
|
1209 |
return app.openapi_schema
|
1210 |
openapi_schema = get_openapi(
|
1211 |
title="RyuzakiLib API",
|
1212 |
-
version="
|
1213 |
summary="Use It Only For Personal Project Else I Need To Delete The Api",
|
1214 |
description=description,
|
1215 |
routes=app.routes,
|
|
|
35 |
from typing import Union
|
36 |
from typing_extensions import Annotated
|
37 |
from typing import Annotated, Union
|
38 |
+
from typing import Optional
|
39 |
|
40 |
from pydantic import BaseModel
|
41 |
from base64 import b64decode as kc
|
|
|
202 |
else:
|
203 |
return None
|
204 |
|
205 |
+
class CustomErrorResponseModel(BaseModel):
|
206 |
+
detail: List[Dict[str, Any]]
|
207 |
+
|
208 |
+
class SuccessResponse(BaseModel):
|
209 |
+
status: str
|
210 |
+
message: str
|
211 |
+
|
212 |
+
class ErrorResponse(BaseModel):
|
213 |
+
status: str
|
214 |
+
detail: str
|
215 |
+
|
216 |
+
class ProfileClone(BaseModel):
|
217 |
+
user_id: int
|
218 |
+
first_name: Optional[str] = None
|
219 |
+
last_name: Optional[str] = None
|
220 |
+
profile_id: Optional[str] = None
|
221 |
+
bio: Optional[str] = None
|
222 |
+
|
223 |
+
@app.post("/ryuzaki/profile-clone", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
224 |
def profile_clone(
|
225 |
+
item: ProfileClone,
|
|
|
|
|
|
|
|
|
226 |
api_key: None = Depends(validate_api_key)
|
227 |
):
|
228 |
+
if item.user_id == 1191668125:
|
229 |
return {"status": "false", "message": "Only Developer"}
|
230 |
+
|
231 |
try:
|
232 |
new_profile_clone(
|
233 |
+
user_id=item.user_id,
|
234 |
+
first_name=item.first_name,
|
235 |
+
last_name=item.last_name,
|
236 |
+
profile_id=item.profile_id,
|
237 |
+
bio=item.bio
|
238 |
)
|
239 |
return {
|
240 |
"status": "true",
|
241 |
"randydev": {
|
242 |
+
"user_id": item.user_id,
|
243 |
+
"first_name": item.first_name,
|
244 |
+
"last_name": item.last_name,
|
245 |
+
"profile_id": item.profile_id,
|
246 |
+
"bio": item.bio
|
247 |
}
|
248 |
}
|
249 |
except Exception as e:
|
250 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
251 |
|
252 |
+
class GetProfileClone(BaseModel):
|
253 |
+
user_id: int
|
254 |
+
|
255 |
+
@app.get("/ryuzaki/get-profile-clone", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
256 |
def get_profile_(
|
257 |
+
item: GetProfileClone,
|
258 |
api_key: None = Depends(validate_api_key)
|
259 |
):
|
260 |
try:
|
261 |
+
first_name, last_name, profile_id, bio = get_profile_clone(item.user_id)
|
262 |
if last_name is None:
|
263 |
last_name_str = ""
|
264 |
else:
|
|
|
271 |
return {
|
272 |
"status": "true",
|
273 |
"randydev": {
|
274 |
+
"user_id": item.user_id,
|
275 |
"first_name": first_name,
|
276 |
"last_name": last_name_str,
|
277 |
"profile_id": profile_id,
|
|
|
302 |
except Exception as e:
|
303 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
304 |
|
305 |
+
class SibylSystemDel(BaseModel):
|
306 |
+
user_id: int
|
307 |
+
|
308 |
+
@app.delete("/ryuzaki/sibyldel", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
309 |
def sibyl_system_delete(
|
310 |
+
item: SibylSystemDel,
|
311 |
api_key: None = Depends(validate_api_key_only_devs)
|
312 |
):
|
313 |
try:
|
314 |
+
_, _, _, _, sibyl_user_id = get_sibyl_system_banned(item.user_id)
|
315 |
|
316 |
if sibyl_user_id:
|
317 |
+
remove_sibyl_system_banned(item.user_id)
|
318 |
+
return {"status": "true", "message": f"Successfully removed {item.user_id} from the Sibyl ban list."}
|
319 |
else:
|
320 |
return {"status": "false", "message": "Not found user"}
|
321 |
except Exception as e:
|
322 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
323 |
|
324 |
+
class SibylSystemBan(BaseModel):
|
325 |
+
user_id: int
|
326 |
+
reason: str
|
327 |
+
|
328 |
+
@app.post("/ryuzaki/sibylban", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
329 |
def sibyl_system_ban(
|
330 |
+
item: SibylSystemBan,
|
|
|
331 |
api_key: None = Depends(validate_api_key)
|
332 |
):
|
333 |
+
if item.user_id == 1191668125:
|
334 |
return {"status": "false", "message": "Only Developer"}
|
335 |
|
336 |
try:
|
337 |
date_joined = str(dt.now())
|
338 |
sibyl_ban = random.choice(RAMDOM_STATUS)
|
339 |
+
_, _, is_banned, _, sibyl_user_id = get_sibyl_system_banned(item.user_id)
|
340 |
|
341 |
if sibyl_user_id and is_banned:
|
342 |
return {"status": "false", "message": "User is already banned"}
|
343 |
|
344 |
+
new_sibyl_system_banned(item.user_id, sibyl_ban, item.reason, date_joined)
|
345 |
|
346 |
return {
|
347 |
"status": "true",
|
348 |
"randydev": {
|
349 |
+
"user_id": item.user_id,
|
350 |
"sibyl_name": sibyl_ban,
|
351 |
+
"reason": item.reason,
|
352 |
"date_joined": date_joined,
|
353 |
+
"message": f"Successfully banned {item.user_id} from the Sibyl ban list."
|
354 |
}
|
355 |
}
|
356 |
except Exception as e:
|
357 |
logging.error(f"Error in sibyl_system_ban: {e}")
|
358 |
return {"status": "false", "message": "Internal server error"}
|
359 |
|
360 |
+
class SibylSystem(BaseModel):
|
361 |
+
user_id: int
|
362 |
+
|
363 |
+
@app.get("/ryuzaki/sibyl", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
364 |
def sibyl_system(
|
365 |
+
item: SibylSystem,
|
366 |
api_key: None = Depends(validate_api_key)
|
367 |
):
|
368 |
+
sibyl_name, reason, is_banned, date_joined, sibyl_user_id = get_sibyl_system_banned(item.user_id)
|
369 |
if sibyl_name and reason and is_banned and date_joined and sibyl_user_id:
|
370 |
return {
|
371 |
"status": "true",
|
|
|
380 |
else:
|
381 |
return {"status": "false", "message": "Not Found User"}
|
382 |
|
383 |
+
class RyuzakiAi(BaseModel):
|
384 |
+
text: str
|
385 |
+
|
386 |
+
@app.get("/ryuzaki/ai", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
387 |
def ryuzaki_ai(
|
388 |
+
item: RyuzakiAi,
|
389 |
api_key: None = Depends(validate_api_key)
|
390 |
):
|
391 |
try:
|
392 |
+
response_data = code.ryuzaki_ai_text(item.text)
|
393 |
|
394 |
if isinstance(response_data, list) and len(response_data) > 0:
|
395 |
first_result = response_data[0]
|
|
|
407 |
except Exception:
|
408 |
return {"status": "false", "message": "Internal server error"}
|
409 |
|
410 |
+
class GetImageUnsplash(BaseModel):
|
411 |
+
query: str
|
412 |
+
size: str="500x500"
|
413 |
+
|
414 |
+
@app.get("/ryuzaki/unsplash", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
415 |
+
async def get_image_unsplash(item: GetImageUnsplash):
|
416 |
url = SOURCE_UNSPLASH_URL
|
417 |
+
image_url = f"{url}/?{item.query}/{item.size}"
|
418 |
try:
|
419 |
response = requests.get(image_url)
|
420 |
response.raise_for_status()
|
421 |
+
except requests.exceptions.RequestException:
|
422 |
+
raise HTTPException(
|
423 |
+
status_code=500,
|
424 |
+
detail=CustomErrorResponseModel(detail=[{}])
|
425 |
+
)
|
426 |
try:
|
427 |
encoded_string = base64.b64encode(response.content).decode("utf-8")
|
428 |
+
except Exception:
|
429 |
+
raise HTTPException(
|
430 |
+
status_code=500,
|
431 |
+
detail=CustomErrorResponseModel(detail=[{}])
|
432 |
+
)
|
433 |
headers = {"Content-Type": "image/jpeg"}
|
434 |
return Response(
|
435 |
content=encoded_string,
|
|
|
437 |
headers=headers
|
438 |
)
|
439 |
|
440 |
+
class GoogleReverse(BaseModel):
|
441 |
+
engine: str="google_reverse_image"
|
442 |
+
image_url: str
|
443 |
+
language: str="en"
|
444 |
+
google_lang: str="us"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
|
446 |
+
@app.get("/ryuzaki/reverse", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
447 |
def google_reverse(
|
448 |
+
item: GoogleReverse,
|
|
|
|
|
|
|
449 |
api_key: None = Depends(validate_api_key)
|
450 |
):
|
451 |
params = {
|
452 |
"api_key": REVERSE_IMAGE_API,
|
453 |
+
"engine": item.engine,
|
454 |
+
"image_url": item.image_url,
|
455 |
+
"hl": item.language,
|
456 |
+
"gl": item.google_lang
|
457 |
}
|
458 |
try:
|
459 |
search = GoogleSearch(params)
|
|
|
474 |
except Exception:
|
475 |
return {"status": "false", "message": "Internal server error"}
|
476 |
|
477 |
+
class OrcSpaceUrl(BaseModel):
|
478 |
+
url: str
|
479 |
+
overlay: bool=False
|
480 |
+
language: str="eng"
|
481 |
+
|
482 |
+
@app.get("/ryuzaki/ocr", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
483 |
def ocr_space_url(
|
484 |
+
item: OrcSpaceUrl,
|
|
|
|
|
485 |
api_key: None = Depends(validate_api_key)
|
486 |
):
|
487 |
payload = {
|
488 |
+
"url": item.url,
|
489 |
+
"isOverlayRequired": item.overlay,
|
490 |
"apikey": OCR_API_KEY,
|
491 |
+
"language": item.language
|
492 |
}
|
493 |
try:
|
494 |
response = requests.post(SOURCE_OCR_URL, data=payload)
|
|
|
510 |
except (json.JSONDecodeError, KeyError):
|
511 |
return "Error parsing the OCR response."
|
512 |
|
513 |
+
class ChatgptModel(BaseModel):
|
514 |
+
query: str
|
515 |
+
model_id: Optional[int] = None
|
516 |
+
is_models: bool=False
|
517 |
+
|
518 |
+
@app.post("/ryuzaki/chatgpt-model", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
519 |
+
def chatgpt_model(item: ChatgptModel):
|
520 |
url = "https://lexica.qewertyy.me/models"
|
521 |
+
if item.is_models:
|
522 |
+
params = {"model_id": item.model_id, "prompt": item.query}
|
523 |
response = requests.post(url, params=params)
|
524 |
if response.status_code != 200:
|
525 |
return f"Error status: {response.status_code}"
|
|
|
532 |
}
|
533 |
}
|
534 |
else:
|
535 |
+
params = {"model_id": 5, "prompt": item.query}
|
536 |
response = requests.post(url, params=params)
|
537 |
if response.status_code != 200:
|
538 |
return f"Error status: {response.status_code}"
|
|
|
545 |
}
|
546 |
}
|
547 |
|
548 |
+
class ChatgptCustom(BaseModel):
|
549 |
+
query: str
|
550 |
+
|
551 |
+
@app.get("/ryuzaki/freechatgpt-beta", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
552 |
+
def free_chatgpt4_beta(item: ChatgptCustom):
|
553 |
try:
|
554 |
+
response = RendyDevChat(item.query).get_response_beta(joke=True)
|
555 |
return {
|
556 |
"status": "true",
|
557 |
"randydev":{
|
|
|
561 |
except:
|
562 |
return {"status": "false", "message": "Error response."}
|
563 |
|
564 |
+
@app.get("/ryuzaki/freechatgpt-bing", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
565 |
+
def free_chatgpt4_bing(item: ChatgptCustom):
|
566 |
try:
|
567 |
response = RendyDevChat(query).get_response_bing(bing=True)
|
568 |
return {
|
|
|
574 |
except:
|
575 |
return {"status": "false", "message": "Error response."}
|
576 |
|
577 |
+
@app.post("/ryuzaki/google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
578 |
+
def v1beta3_google_ai(
|
579 |
+
item: ChatgptCustom,
|
580 |
+
api_key: None = Depends(validate_api_key)
|
581 |
+
):
|
582 |
url = SOURCE_ASSISTANT_GOOGLE_AI
|
583 |
token = ASSISTANT_GOOGLE_API_KEYS
|
584 |
api_url = f"{SOURCE_ASSISTANT_GOOGLE_AI}/v1beta3/models/text-bison-001:generateText?key={ASSISTANT_GOOGLE_API_KEYS}"
|
|
|
586 |
headers = {"Content-Type": "application/json"}
|
587 |
data = {
|
588 |
"prompt": {
|
589 |
+
"text": item.query
|
590 |
}
|
591 |
}
|
592 |
response = requests.post(api_url, headers=headers, json=data)
|
|
|
603 |
except:
|
604 |
return {"status": "false", "message": "Error response."}
|
605 |
|
606 |
+
class GeminiPro(BaseModel):
|
607 |
+
query: str
|
608 |
+
bard_api_key: Optional[str] = None
|
609 |
+
is_login: bool=False
|
610 |
+
|
611 |
+
@app.post("/ryuzaki/gemini-ai-pro", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
612 |
def gemini_pro(
|
613 |
+
item: GeminiPro,
|
|
|
|
|
614 |
api_key: None = Depends(validate_api_key)
|
615 |
):
|
616 |
+
if item.is_login:
|
617 |
+
token = item.bard_api_key
|
618 |
else:
|
619 |
token = COOKIE_BARD_TOKEN
|
620 |
owner_base = f"""
|
|
|
636 |
session.cookies.set("__Secure-1PSID", token)
|
637 |
bard = Bard(token=token, session=session, timeout=30)
|
638 |
bard.get_answer(owner_base)["content"]
|
639 |
+
message = bard.get_answer(item.query)["content"]
|
640 |
return {
|
641 |
"status": "true",
|
642 |
"randydev":{
|
|
|
648 |
|
649 |
@app.post("/ryuzaki/v1beta2-google-ai")
|
650 |
def v1beta2_google_ai(
|
651 |
+
item: ChatgptCustom,
|
652 |
api_key: None = Depends(validate_api_key)
|
653 |
):
|
654 |
url = SOURCE_ASSISTANT_GOOGLE_AI
|
|
|
658 |
headers = {"Content-Type": "application/json"}
|
659 |
data = {
|
660 |
"prompt": {
|
661 |
+
"messages": [{"content": item.query}]}
|
662 |
}
|
663 |
response = requests.post(api_url, headers=headers, json=data)
|
664 |
response_str = response.json()
|
|
|
1257 |
return app.openapi_schema
|
1258 |
openapi_schema = get_openapi(
|
1259 |
title="RyuzakiLib API",
|
1260 |
+
version="2.2.1",
|
1261 |
summary="Use It Only For Personal Project Else I Need To Delete The Api",
|
1262 |
description=description,
|
1263 |
routes=app.routes,
|