Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -214,6 +214,10 @@ class ErrorResponse(BaseModel):
|
|
214 |
status: str
|
215 |
detail: str
|
216 |
|
|
|
|
|
|
|
|
|
217 |
class ProfileClone(BaseModel):
|
218 |
user_id: int
|
219 |
first_name: Optional[str] = None
|
@@ -221,7 +225,51 @@ class ProfileClone(BaseModel):
|
|
221 |
profile_id: Optional[str] = None
|
222 |
bio: Optional[str] = None
|
223 |
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
def profile_clone(
|
226 |
item: ProfileClone,
|
227 |
api_key: None = Depends(validate_api_key)
|
@@ -237,23 +285,20 @@ def profile_clone(
|
|
237 |
profile_id=item.profile_id,
|
238 |
bio=item.bio
|
239 |
)
|
240 |
-
return
|
241 |
-
|
242 |
-
|
243 |
"user_id": item.user_id,
|
244 |
"first_name": item.first_name,
|
245 |
"last_name": item.last_name,
|
246 |
"profile_id": item.profile_id,
|
247 |
"bio": item.bio
|
248 |
}
|
249 |
-
|
250 |
except Exception as e:
|
251 |
-
return
|
252 |
|
253 |
-
|
254 |
-
user_id: int
|
255 |
-
|
256 |
-
@app.get("/ryuzaki/get-profile-clone", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
257 |
def get_profile_(
|
258 |
item: GetProfileClone,
|
259 |
api_key: None = Depends(validate_api_key)
|
@@ -269,20 +314,20 @@ def get_profile_(
|
|
269 |
else:
|
270 |
bio_str = bio
|
271 |
if first_name and profile_id:
|
272 |
-
return
|
273 |
-
|
274 |
-
|
275 |
"user_id": item.user_id,
|
276 |
"first_name": first_name,
|
277 |
"last_name": last_name_str,
|
278 |
"profile_id": profile_id,
|
279 |
"bio": bio_str
|
280 |
}
|
281 |
-
|
282 |
else:
|
283 |
-
return
|
284 |
except Exception as e:
|
285 |
-
return
|
286 |
|
287 |
@app.get("/ryuzaki/getbanlist")
|
288 |
def sibyl_get_all_banlist():
|
@@ -303,10 +348,7 @@ def blacklist_words():
|
|
303 |
except Exception as e:
|
304 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
305 |
|
306 |
-
|
307 |
-
user_id: int
|
308 |
-
|
309 |
-
@app.delete("/ryuzaki/sibyldel", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
310 |
def sibyl_system_delete(
|
311 |
item: SibylSystemDel,
|
312 |
api_key: None = Depends(validate_api_key_only_devs)
|
@@ -316,17 +358,18 @@ def sibyl_system_delete(
|
|
316 |
|
317 |
if sibyl_user_id:
|
318 |
remove_sibyl_system_banned(item.user_id)
|
319 |
-
return
|
|
|
|
|
|
|
|
|
|
|
320 |
else:
|
321 |
-
return
|
322 |
except Exception as e:
|
323 |
-
return
|
324 |
-
|
325 |
-
class SibylSystemBan(BaseModel):
|
326 |
-
user_id: int
|
327 |
-
reason: str
|
328 |
|
329 |
-
@app.post("/ryuzaki/sibylban", response_model=SuccessResponse, responses={422: {"model":
|
330 |
def sibyl_system_ban(
|
331 |
item: SibylSystemBan,
|
332 |
api_key: None = Depends(validate_api_key)
|
@@ -343,48 +386,40 @@ def sibyl_system_ban(
|
|
343 |
return {"status": "false", "message": "User is already banned"}
|
344 |
|
345 |
new_sibyl_system_banned(item.user_id, sibyl_ban, item.reason, date_joined)
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
"randydev": {
|
350 |
"user_id": item.user_id,
|
351 |
"sibyl_name": sibyl_ban,
|
352 |
"reason": item.reason,
|
353 |
"date_joined": date_joined,
|
354 |
"message": f"Successfully banned {item.user_id} from the Sibyl ban list."
|
355 |
}
|
356 |
-
|
357 |
except Exception as e:
|
358 |
-
|
359 |
-
return {"status": "false", "message": "Internal server error"}
|
360 |
-
|
361 |
-
class SibylSystem(BaseModel):
|
362 |
-
user_id: int
|
363 |
|
364 |
-
@app.get("/ryuzaki/sibyl", response_model=SuccessResponse, responses={422: {"model":
|
365 |
def sibyl_system(
|
366 |
item: SibylSystem,
|
367 |
api_key: None = Depends(validate_api_key)
|
368 |
):
|
369 |
sibyl_name, reason, is_banned, date_joined, sibyl_user_id = get_sibyl_system_banned(item.user_id)
|
370 |
if sibyl_name and reason and is_banned and date_joined and sibyl_user_id:
|
371 |
-
return
|
372 |
-
|
373 |
-
|
374 |
"sibyl_name": sibyl_name,
|
375 |
"reason": reason,
|
376 |
"is_banned": is_banned,
|
377 |
"date_joined": date_joined,
|
378 |
"sibyl_user_id": sibyl_user_id
|
379 |
}
|
380 |
-
|
381 |
else:
|
382 |
-
return
|
383 |
-
|
384 |
-
class RyuzakiAi(BaseModel):
|
385 |
-
text: str
|
386 |
|
387 |
-
@app.get("/ryuzaki/ai", response_model=SuccessResponse, responses={422: {"model":
|
388 |
def ryuzaki_ai(
|
389 |
item: RyuzakiAi,
|
390 |
api_key: None = Depends(validate_api_key)
|
@@ -396,23 +431,18 @@ def ryuzaki_ai(
|
|
396 |
first_result = response_data[0]
|
397 |
if "generated_text" in first_result:
|
398 |
message = first_result["generated_text"]
|
399 |
-
return
|
400 |
-
|
401 |
-
|
402 |
"ryuzaki_text": message
|
403 |
}
|
404 |
-
|
405 |
-
|
406 |
return {"status": "false", "message": "Invalid response format"}
|
407 |
|
408 |
except Exception:
|
409 |
return {"status": "false", "message": "Internal server error"}
|
410 |
|
411 |
-
|
412 |
-
query: str
|
413 |
-
size: str="500x500"
|
414 |
-
|
415 |
-
@app.get("/ryuzaki/unsplash", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
416 |
async def get_image_unsplash(item: GetImageUnsplash):
|
417 |
url = SOURCE_UNSPLASH_URL
|
418 |
image_url = f"{url}/?{item.query}/{item.size}"
|
@@ -438,13 +468,7 @@ async def get_image_unsplash(item: GetImageUnsplash):
|
|
438 |
headers=headers
|
439 |
)
|
440 |
|
441 |
-
|
442 |
-
engine: str="google_reverse_image"
|
443 |
-
image_url: str
|
444 |
-
language: str="en"
|
445 |
-
google_lang: str="us"
|
446 |
-
|
447 |
-
@app.get("/ryuzaki/reverse", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
448 |
def google_reverse(
|
449 |
item: GoogleReverse,
|
450 |
api_key: None = Depends(validate_api_key)
|
@@ -463,24 +487,19 @@ def google_reverse(
|
|
463 |
total_time_taken = results["search_metadata"]["total_time_taken"]
|
464 |
create_at = results["search_metadata"]["created_at"]
|
465 |
processed_at = results["search_metadata"]["processed_at"]
|
466 |
-
return
|
467 |
-
|
468 |
-
|
469 |
"link": link,
|
470 |
"total_time_taken": total_time_taken,
|
471 |
"create_at": create_at,
|
472 |
"processed_at": processed_at
|
473 |
}
|
474 |
-
|
475 |
except Exception:
|
476 |
return {"status": "false", "message": "Internal server error"}
|
477 |
|
478 |
-
|
479 |
-
url: str
|
480 |
-
overlay: bool=False
|
481 |
-
language: str="eng"
|
482 |
-
|
483 |
-
@app.get("/ryuzaki/ocr", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
484 |
def ocr_space_url(
|
485 |
item: OrcSpaceUrl,
|
486 |
api_key: None = Depends(validate_api_key)
|
@@ -500,23 +519,18 @@ def ocr_space_url(
|
|
500 |
try:
|
501 |
parsed_response = json.loads(test_url)
|
502 |
if "ParsedResults" in parsed_response and len(parsed_response["ParsedResults"]) > 0:
|
503 |
-
return
|
504 |
-
|
505 |
-
|
506 |
"text": parsed_response["ParsedResults"][0]["ParsedText"]
|
507 |
}
|
508 |
-
|
509 |
else:
|
510 |
return {"status": "false", "message": "Error response."}
|
511 |
except (json.JSONDecodeError, KeyError):
|
512 |
return "Error parsing the OCR response."
|
513 |
|
514 |
-
|
515 |
-
query: str
|
516 |
-
model_id: Optional[int] = None
|
517 |
-
is_models: bool=False
|
518 |
-
|
519 |
-
@app.post("/ryuzaki/chatgpt-model", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
520 |
def chatgpt_model(item: ChatgptModel):
|
521 |
url = "https://lexica.qewertyy.me/models"
|
522 |
if item.is_models:
|
@@ -526,12 +540,12 @@ def chatgpt_model(item: ChatgptModel):
|
|
526 |
return f"Error status: {response.status_code}"
|
527 |
check_response = response.json()
|
528 |
answer = check_response.get("content")
|
529 |
-
return
|
530 |
-
|
531 |
-
|
532 |
"message": answer
|
533 |
}
|
534 |
-
|
535 |
else:
|
536 |
params = {"model_id": 5, "prompt": item.query}
|
537 |
response = requests.post(url, params=params)
|
@@ -539,43 +553,40 @@ def chatgpt_model(item: ChatgptModel):
|
|
539 |
return f"Error status: {response.status_code}"
|
540 |
check_response = response.json()
|
541 |
answer = check_response.get("content")
|
542 |
-
return
|
543 |
-
|
544 |
-
|
545 |
"message": answer
|
546 |
}
|
547 |
-
|
548 |
-
|
549 |
-
class ChatgptCustom(BaseModel):
|
550 |
-
query: str
|
551 |
|
552 |
-
@app.get("/ryuzaki/freechatgpt-beta", response_model=SuccessResponse, responses={422: {"model":
|
553 |
def free_chatgpt4_beta(item: ChatgptCustom):
|
554 |
try:
|
555 |
response = RendyDevChat(item.query).get_response_beta(joke=True)
|
556 |
-
return
|
557 |
-
|
558 |
-
|
559 |
"message": response
|
560 |
}
|
561 |
-
|
562 |
except:
|
563 |
return {"status": "false", "message": "Error response."}
|
564 |
|
565 |
-
@app.get("/ryuzaki/freechatgpt-bing", response_model=SuccessResponse, responses={422: {"model":
|
566 |
def free_chatgpt4_bing(item: ChatgptCustom):
|
567 |
try:
|
568 |
response = RendyDevChat(query).get_response_bing(bing=True)
|
569 |
-
return
|
570 |
-
|
571 |
-
|
572 |
"message": response
|
573 |
}
|
574 |
-
|
575 |
except:
|
576 |
return {"status": "false", "message": "Error response."}
|
577 |
|
578 |
-
@app.post("/ryuzaki/google-ai", response_model=SuccessResponse, responses={422: {"model":
|
579 |
def v1beta3_google_ai(
|
580 |
item: ChatgptCustom,
|
581 |
api_key: None = Depends(validate_api_key)
|
@@ -595,21 +606,16 @@ def v1beta3_google_ai(
|
|
595 |
answer = response_str["candidates"]
|
596 |
for results in answer:
|
597 |
message = results.get("output")
|
598 |
-
return
|
599 |
-
|
600 |
-
|
601 |
"message": message
|
602 |
}
|
603 |
-
|
604 |
except:
|
605 |
return {"status": "false", "message": "Error response."}
|
606 |
|
607 |
-
|
608 |
-
query: str
|
609 |
-
bard_api_key: Optional[str] = None
|
610 |
-
is_login: bool=False
|
611 |
-
|
612 |
-
@app.post("/ryuzaki/gemini-ai-pro", response_model=SuccessResponse, responses={422: {"model": ErrorResponse}})
|
613 |
def gemini_pro(
|
614 |
item: GeminiPro,
|
615 |
api_key: None = Depends(validate_api_key)
|
@@ -638,16 +644,16 @@ def gemini_pro(
|
|
638 |
bard = Bard(token=token, session=session, timeout=30)
|
639 |
bard.get_answer(owner_base)["content"]
|
640 |
message = bard.get_answer(item.query)["content"]
|
641 |
-
return
|
642 |
-
|
643 |
-
|
644 |
"message": message
|
645 |
}
|
646 |
-
|
647 |
except:
|
648 |
return {"status": "false", "message": "Error response."}
|
649 |
|
650 |
-
@app.post("/ryuzaki/v1beta2-google-ai")
|
651 |
def v1beta2_google_ai(
|
652 |
item: ChatgptCustom,
|
653 |
api_key: None = Depends(validate_api_key)
|
@@ -666,12 +672,12 @@ def v1beta2_google_ai(
|
|
666 |
answer = response_str["candidates"]
|
667 |
for results in answer:
|
668 |
message = results.get("content")
|
669 |
-
return
|
670 |
-
|
671 |
-
|
672 |
"message": message
|
673 |
}
|
674 |
-
|
675 |
except:
|
676 |
return {"status": "false", "message": "Error response."}
|
677 |
|
|
|
214 |
status: str
|
215 |
detail: str
|
216 |
|
217 |
+
class ErrorStatus(BaseModel):
|
218 |
+
status: str
|
219 |
+
message: str
|
220 |
+
|
221 |
class ProfileClone(BaseModel):
|
222 |
user_id: int
|
223 |
first_name: Optional[str] = None
|
|
|
225 |
profile_id: Optional[str] = None
|
226 |
bio: Optional[str] = None
|
227 |
|
228 |
+
class GetProfileClone(BaseModel):
|
229 |
+
user_id: int
|
230 |
+
|
231 |
+
class SibylSystemDel(BaseModel):
|
232 |
+
user_id: int
|
233 |
+
|
234 |
+
class SibylSystemBan(BaseModel):
|
235 |
+
user_id: int
|
236 |
+
reason: str
|
237 |
+
|
238 |
+
class RyuzakiAi(BaseModel):
|
239 |
+
text: str
|
240 |
+
|
241 |
+
class SibylSystem(BaseModel):
|
242 |
+
user_id: int
|
243 |
+
|
244 |
+
class GoogleReverse(BaseModel):
|
245 |
+
engine: str="google_reverse_image"
|
246 |
+
image_url: str
|
247 |
+
language: str="en"
|
248 |
+
google_lang: str="us"
|
249 |
+
|
250 |
+
class GetImageUnsplash(BaseModel):
|
251 |
+
query: str
|
252 |
+
size: str="500x500"
|
253 |
+
|
254 |
+
class OrcSpaceUrl(BaseModel):
|
255 |
+
url: str
|
256 |
+
overlay: bool=False
|
257 |
+
language: str="eng"
|
258 |
+
|
259 |
+
class ChatgptModel(BaseModel):
|
260 |
+
query: str
|
261 |
+
model_id: Optional[int] = None
|
262 |
+
is_models: bool=False
|
263 |
+
|
264 |
+
class ChatgptCustom(BaseModel):
|
265 |
+
query: str
|
266 |
+
|
267 |
+
class GeminiPro(BaseModel):
|
268 |
+
query: str
|
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,
|
275 |
api_key: None = Depends(validate_api_key)
|
|
|
285 |
profile_id=item.profile_id,
|
286 |
bio=item.bio
|
287 |
)
|
288 |
+
return SuccessResponse(
|
289 |
+
status="True",
|
290 |
+
randydev={
|
291 |
"user_id": item.user_id,
|
292 |
"first_name": item.first_name,
|
293 |
"last_name": item.last_name,
|
294 |
"profile_id": item.profile_id,
|
295 |
"bio": item.bio
|
296 |
}
|
297 |
+
)
|
298 |
except Exception as e:
|
299 |
+
return ErrorStatus(status="false", message=f"Internal server error: {str(e)}")
|
300 |
|
301 |
+
@app.get("/ryuzaki/get-profile-clone", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
|
|
|
|
|
|
302 |
def get_profile_(
|
303 |
item: GetProfileClone,
|
304 |
api_key: None = Depends(validate_api_key)
|
|
|
314 |
else:
|
315 |
bio_str = bio
|
316 |
if first_name and profile_id:
|
317 |
+
return SuccessResponse(
|
318 |
+
status="True",
|
319 |
+
randydev={
|
320 |
"user_id": item.user_id,
|
321 |
"first_name": first_name,
|
322 |
"last_name": last_name_str,
|
323 |
"profile_id": profile_id,
|
324 |
"bio": bio_str
|
325 |
}
|
326 |
+
)
|
327 |
else:
|
328 |
+
return ErrorStatus(status="false", message="Not found user")
|
329 |
except Exception as e:
|
330 |
+
return ErrorStatus(status="false", message=f"Internal server error: {str(e)}")
|
331 |
|
332 |
@app.get("/ryuzaki/getbanlist")
|
333 |
def sibyl_get_all_banlist():
|
|
|
348 |
except Exception as e:
|
349 |
return {"status": "false", "message": f"Internal server error: {str(e)}"}
|
350 |
|
351 |
+
@app.delete("/ryuzaki/sibyldel", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
|
|
|
|
|
|
352 |
def sibyl_system_delete(
|
353 |
item: SibylSystemDel,
|
354 |
api_key: None = Depends(validate_api_key_only_devs)
|
|
|
358 |
|
359 |
if sibyl_user_id:
|
360 |
remove_sibyl_system_banned(item.user_id)
|
361 |
+
return SuccessResponse(
|
362 |
+
status="True",
|
363 |
+
randydev={
|
364 |
+
"message": f"Successfully removed {item.user_id} from the Sibyl ban list"
|
365 |
+
}
|
366 |
+
)
|
367 |
else:
|
368 |
+
return ErrorStatus(status="false", message="Not found user")
|
369 |
except Exception as e:
|
370 |
+
return ErrorStatus(status="false", message=f"Internal server error: {str(e)}")
|
|
|
|
|
|
|
|
|
371 |
|
372 |
+
@app.post("/ryuzaki/sibylban", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
373 |
def sibyl_system_ban(
|
374 |
item: SibylSystemBan,
|
375 |
api_key: None = Depends(validate_api_key)
|
|
|
386 |
return {"status": "false", "message": "User is already banned"}
|
387 |
|
388 |
new_sibyl_system_banned(item.user_id, sibyl_ban, item.reason, date_joined)
|
389 |
+
return SuccessResponse(
|
390 |
+
status="True",
|
391 |
+
randydev={
|
|
|
392 |
"user_id": item.user_id,
|
393 |
"sibyl_name": sibyl_ban,
|
394 |
"reason": item.reason,
|
395 |
"date_joined": date_joined,
|
396 |
"message": f"Successfully banned {item.user_id} from the Sibyl ban list."
|
397 |
}
|
398 |
+
)
|
399 |
except Exception as e:
|
400 |
+
return ErrorStatus(status="false", message=f"Internal server error: {str(e)}")
|
|
|
|
|
|
|
|
|
401 |
|
402 |
+
@app.get("/ryuzaki/sibyl", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
403 |
def sibyl_system(
|
404 |
item: SibylSystem,
|
405 |
api_key: None = Depends(validate_api_key)
|
406 |
):
|
407 |
sibyl_name, reason, is_banned, date_joined, sibyl_user_id = get_sibyl_system_banned(item.user_id)
|
408 |
if sibyl_name and reason and is_banned and date_joined and sibyl_user_id:
|
409 |
+
return SuccessResponse(
|
410 |
+
status="True",
|
411 |
+
randydev={
|
412 |
"sibyl_name": sibyl_name,
|
413 |
"reason": reason,
|
414 |
"is_banned": is_banned,
|
415 |
"date_joined": date_joined,
|
416 |
"sibyl_user_id": sibyl_user_id
|
417 |
}
|
418 |
+
)
|
419 |
else:
|
420 |
+
return ErrorStatus(status="false", message="Not found user")
|
|
|
|
|
|
|
421 |
|
422 |
+
@app.get("/ryuzaki/ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
423 |
def ryuzaki_ai(
|
424 |
item: RyuzakiAi,
|
425 |
api_key: None = Depends(validate_api_key)
|
|
|
431 |
first_result = response_data[0]
|
432 |
if "generated_text" in first_result:
|
433 |
message = first_result["generated_text"]
|
434 |
+
return SuccessResponse(
|
435 |
+
status="True",
|
436 |
+
randydev={
|
437 |
"ryuzaki_text": message
|
438 |
}
|
439 |
+
)
|
|
|
440 |
return {"status": "false", "message": "Invalid response format"}
|
441 |
|
442 |
except Exception:
|
443 |
return {"status": "false", "message": "Internal server error"}
|
444 |
|
445 |
+
@app.get("/ryuzaki/unsplash", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
|
|
|
|
|
|
|
|
446 |
async def get_image_unsplash(item: GetImageUnsplash):
|
447 |
url = SOURCE_UNSPLASH_URL
|
448 |
image_url = f"{url}/?{item.query}/{item.size}"
|
|
|
468 |
headers=headers
|
469 |
)
|
470 |
|
471 |
+
@app.get("/ryuzaki/reverse", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
def google_reverse(
|
473 |
item: GoogleReverse,
|
474 |
api_key: None = Depends(validate_api_key)
|
|
|
487 |
total_time_taken = results["search_metadata"]["total_time_taken"]
|
488 |
create_at = results["search_metadata"]["created_at"]
|
489 |
processed_at = results["search_metadata"]["processed_at"]
|
490 |
+
return SuccessResponse(
|
491 |
+
status="True",
|
492 |
+
randydev={
|
493 |
"link": link,
|
494 |
"total_time_taken": total_time_taken,
|
495 |
"create_at": create_at,
|
496 |
"processed_at": processed_at
|
497 |
}
|
498 |
+
)
|
499 |
except Exception:
|
500 |
return {"status": "false", "message": "Internal server error"}
|
501 |
|
502 |
+
@app.get("/ryuzaki/ocr", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
|
|
|
|
|
|
|
|
|
|
503 |
def ocr_space_url(
|
504 |
item: OrcSpaceUrl,
|
505 |
api_key: None = Depends(validate_api_key)
|
|
|
519 |
try:
|
520 |
parsed_response = json.loads(test_url)
|
521 |
if "ParsedResults" in parsed_response and len(parsed_response["ParsedResults"]) > 0:
|
522 |
+
return SuccessResponse(
|
523 |
+
status="True",
|
524 |
+
randydev={
|
525 |
"text": parsed_response["ParsedResults"][0]["ParsedText"]
|
526 |
}
|
527 |
+
)
|
528 |
else:
|
529 |
return {"status": "false", "message": "Error response."}
|
530 |
except (json.JSONDecodeError, KeyError):
|
531 |
return "Error parsing the OCR response."
|
532 |
|
533 |
+
@app.post("/ryuzaki/chatgpt-model", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
|
|
|
|
|
|
|
|
|
|
534 |
def chatgpt_model(item: ChatgptModel):
|
535 |
url = "https://lexica.qewertyy.me/models"
|
536 |
if item.is_models:
|
|
|
540 |
return f"Error status: {response.status_code}"
|
541 |
check_response = response.json()
|
542 |
answer = check_response.get("content")
|
543 |
+
return SuccessResponse(
|
544 |
+
status="True",
|
545 |
+
randydev={
|
546 |
"message": answer
|
547 |
}
|
548 |
+
)
|
549 |
else:
|
550 |
params = {"model_id": 5, "prompt": item.query}
|
551 |
response = requests.post(url, params=params)
|
|
|
553 |
return f"Error status: {response.status_code}"
|
554 |
check_response = response.json()
|
555 |
answer = check_response.get("content")
|
556 |
+
return SuccessResponse(
|
557 |
+
status="True",
|
558 |
+
randydev={
|
559 |
"message": answer
|
560 |
}
|
561 |
+
)
|
|
|
|
|
|
|
562 |
|
563 |
+
@app.get("/ryuzaki/freechatgpt-beta", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
564 |
def free_chatgpt4_beta(item: ChatgptCustom):
|
565 |
try:
|
566 |
response = RendyDevChat(item.query).get_response_beta(joke=True)
|
567 |
+
return SuccessResponse(
|
568 |
+
status="True",
|
569 |
+
randydev={
|
570 |
"message": response
|
571 |
}
|
572 |
+
)
|
573 |
except:
|
574 |
return {"status": "false", "message": "Error response."}
|
575 |
|
576 |
+
@app.get("/ryuzaki/freechatgpt-bing", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
577 |
def free_chatgpt4_bing(item: ChatgptCustom):
|
578 |
try:
|
579 |
response = RendyDevChat(query).get_response_bing(bing=True)
|
580 |
+
return SuccessResponse(
|
581 |
+
status="True",
|
582 |
+
randydev={
|
583 |
"message": response
|
584 |
}
|
585 |
+
)
|
586 |
except:
|
587 |
return {"status": "false", "message": "Error response."}
|
588 |
|
589 |
+
@app.post("/ryuzaki/google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
590 |
def v1beta3_google_ai(
|
591 |
item: ChatgptCustom,
|
592 |
api_key: None = Depends(validate_api_key)
|
|
|
606 |
answer = response_str["candidates"]
|
607 |
for results in answer:
|
608 |
message = results.get("output")
|
609 |
+
return SuccessResponse(
|
610 |
+
status="True",
|
611 |
+
randydev={
|
612 |
"message": message
|
613 |
}
|
614 |
+
)
|
615 |
except:
|
616 |
return {"status": "false", "message": "Error response."}
|
617 |
|
618 |
+
@app.post("/ryuzaki/gemini-ai-pro", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
|
|
|
|
|
|
|
|
|
|
619 |
def gemini_pro(
|
620 |
item: GeminiPro,
|
621 |
api_key: None = Depends(validate_api_key)
|
|
|
644 |
bard = Bard(token=token, session=session, timeout=30)
|
645 |
bard.get_answer(owner_base)["content"]
|
646 |
message = bard.get_answer(item.query)["content"]
|
647 |
+
return SuccessResponse(
|
648 |
+
status="True",
|
649 |
+
randydev={
|
650 |
"message": message
|
651 |
}
|
652 |
+
)
|
653 |
except:
|
654 |
return {"status": "false", "message": "Error response."}
|
655 |
|
656 |
+
@app.post("/ryuzaki/v1beta2-google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
|
657 |
def v1beta2_google_ai(
|
658 |
item: ChatgptCustom,
|
659 |
api_key: None = Depends(validate_api_key)
|
|
|
672 |
answer = response_str["candidates"]
|
673 |
for results in answer:
|
674 |
message = results.get("content")
|
675 |
+
return SuccessResponse(
|
676 |
+
status="True",
|
677 |
+
randydev={
|
678 |
"message": message
|
679 |
}
|
680 |
+
)
|
681 |
except:
|
682 |
return {"status": "false", "message": "Error response."}
|
683 |
|