diff --git a/RyuzakiLib/__init__.py b/RyuzakiLib/__init__.py index b8465c6..6cb4f25 100644 --- a/RyuzakiLib/__init__.py +++ b/RyuzakiLib/__init__.py @@ -38,6 +38,7 @@ from .extreme.quotestk import QouteSticker from .extreme.userinfo import TelegramUserInfo from .extreme.webshot import WebShotUrl +from .fastapi import FastAPISuper from .hackertools.blackbox import Blackbox from .hackertools.chatgpt import RendyDevChat from .hackertools.cloudflare import CloudFlare @@ -118,4 +119,5 @@ class AwesomeCoding(BaseModel): "async_search", "PornoHub", "AkenoAI", + "FastAPISuper", ] diff --git a/RyuzakiLib/__version__.py b/RyuzakiLib/__version__.py index f708a9b..7b1e312 100644 --- a/RyuzakiLib/__version__.py +++ b/RyuzakiLib/__version__.py @@ -1 +1 @@ -__version__ = "1.3.2" +__version__ = "1.3.3" diff --git a/RyuzakiLib/akenoai.py b/RyuzakiLib/akenoai.py index e68825d..4bfefa8 100644 --- a/RyuzakiLib/akenoai.py +++ b/RyuzakiLib/akenoai.py @@ -20,7 +20,10 @@ async def signup(self, gmail: str, username: str): return response async def connect(self, username: str, requests_limit: int = 30): - response = await self.get_api_key(username) + response = await async_search( + f"{self.base_api_dev}/get_api_key?api_key={username}", + re_json=True + ) if response.get("requests_made", 0) >= requests_limit: return "The limit has been reached" else: diff --git a/RyuzakiLib/fastapi.py b/RyuzakiLib/fastapi.py new file mode 100644 index 0000000..64601de --- /dev/null +++ b/RyuzakiLib/fastapi.py @@ -0,0 +1,60 @@ +from authlib.integrations.starlette_client import OAuth +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware +from starlette.middleware.sessions import SessionMiddleware + + +class FastAPISuper: + def __init__(self, docs_url=None, redoc_url=None, config=None): + self.docs_url = docs_url + self.redoc_url = redoc_url + self.fastapi = FastAPI(docs_url=self.docs_url, redoc_url=self.redoc_url) + self.auth = OAuth(config) + + def auth_register( + self, + auth0_client_id=None, + auth0_client_secrect=None, + auth0_domain=None, + domain_url=None + ): + self.auth.register( + name="auth0", + client_id=auth0_client_id, + client_secret=auth0_client_secrect, + client_kwargs={ + "scope": "openid profile email", + "redirect_url": f"{domain_url}/callback" + }, + server_metadata_url=f"https://{auth0_domain}/.well-known/openid-configuration" + ) + + async def authorize_redirect(self, request=None, redirect_uri=None): + return await self.auth.auth0.authorize_redirect( + request, + redirect_uri=redirect_uri, + scope="openid profile email", + response_type="code" + ) + + async def authorize_access_token(self, request=None): + token = await self.auth.auth0.authorize_access_token(request) + return token + + def moderator(self): + return self.fastapi + + def add_session_middleware(self, secret_key=None): + self.fastapi.add_middleware( + SessionMiddleware, + secret_key=secret_key + ) + + def add_cors_middleware(self): + self.fastapi.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) diff --git a/RyuzakiLib/hackertools/chatgpt.py b/RyuzakiLib/hackertools/chatgpt.py index fbbaa23..978191f 100644 --- a/RyuzakiLib/hackertools/chatgpt.py +++ b/RyuzakiLib/hackertools/chatgpt.py @@ -55,9 +55,13 @@ async def chat_hacked( mongo_url: Optional[str] = None, system_prompt: Optional[str] = owner_base, list_model_all: Optional[bool] = False + is_working_dev: Optional[bool] = False ): if latest_model == "openai-v2": - url = f"{base_api_dev}/ryuzaki/chatgpt-old" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/chatgpt-old" + else: + url "https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-old" params = {"query": args} check_response = await AsyicXSearcher.search( url, @@ -67,7 +71,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "blackbox": - url = f"{base_api_dev}/ryuzaki/blackbox" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/blackbox" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/blackbox" params = {"query": args} check_response = await AsyicXSearcher.search( url, @@ -89,7 +96,10 @@ async def chat_hacked( else: return "you can check set list_model_all=True" elif latest_model == "gemini-pro": - url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/gemini-ai-pro" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/gemini-ai-pro" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/gemini-ai-pro" payload = { "query": args, "mongo_url": mongo_url, @@ -106,7 +116,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "microsoft": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "microsoft/Phi-3-mini-4k-instruct", @@ -121,7 +134,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "gemma": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "google/gemma-1.1-7b-it", @@ -136,7 +152,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "mistralai": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "mistralai/Mixtral-8x7B-Instruct-v0.1", @@ -151,7 +170,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "faceh4": - url = f"{base_api_dev}/ryuzaki/faceai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/faceai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/faceai" payload = { "query": args, "clients_name": "HuggingFaceH4/zephyr-7b-beta", @@ -166,7 +188,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "google-ai": - url = f"{base_api_dev}/ryuzaki/google-ai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/google-ai" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} check_response = await AsyicXSearcher.search( @@ -178,7 +203,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "betagoogle-ai": - url = f"{base_api_dev}/ryuzaki/v1beta2-google-ai" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/v1beta2-google-ai" + else: + url = "https://randydev-ryuzaki-api.hf.space/ryuzaki/v1beta2-google-ai" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args} check_response = await AsyicXSearcher.search( @@ -190,7 +218,10 @@ async def chat_hacked( ) return check_response["randydev"]["message"] elif latest_model == "gpt-4-turbo": - url = f"{base_api_dev}/ryuzaki/chatgpt-custom" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/chatgpt-custom" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/chatgpt-custom" headers = {"accept": "application/json", "api-key": API_KEYS} params = {"query": args, "model": "gpt-4-turbo"} check_response = await AsyicXSearcher.search( @@ -223,7 +254,10 @@ def download_images(image_urls): @staticmethod async def image_generator(args): - url = f"{base_api_dev}/ryuzaki/dalle3xl" + if is_working_dev: + url = f"{base_api_dev}/ryuzaki/dalle3xl" + else: + url = f"https://randydev-ryuzaki-api.hf.space/ryuzaki/dalle3xl" headers = {"accept": "application/json", "api-key": API_KEYS} payload = {"query": args} check_response = await AsyicXSearcher.search( diff --git a/requirements.txt b/requirements.txt index 4795d02..32c7196 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,3 +30,6 @@ huggingface-hub>=0.23.2 motor nest-asyncio wget +uvicorn[standard +fastapi[all] +authlib diff --git a/setup.py b/setup.py index 1073555..f70f088 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,9 @@ def read(fname, version=False): "huggingface-hub>=0.23.2", "motor", "wget", + "uvicorn[standard", + "fastapi[all]", + "authlib", ], classifiers=[ "Programming Language :: Python :: 3",