randydev commited on
Commit
60724c7
1 Parent(s): 80ddb84

Upload 2 files

Browse files
Files changed (2) hide show
  1. main.py +9 -0
  2. template.py +51 -0
main.py CHANGED
@@ -75,6 +75,7 @@ from RyuzakiLib.system import System
75
 
76
  from bardapi import Bard
77
  from models import *
 
78
  from gpytranslate import SyncTranslator
79
 
80
  import logging
@@ -861,6 +862,14 @@ def beta_rag(item: BetaRags):
861
  except Exception as e:
862
  return SuccessResponse(status="False", randydev={"message": str(e)})
863
 
 
 
 
 
 
 
 
 
864
  @app.post("/ryuzaki/gemini-ai-pro", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
865
  def gemini_pro(item: GeminiPro):
866
  owner_base = f"""
 
75
 
76
  from bardapi import Bard
77
  from models import *
78
+ from template import send_blackbox_chat
79
  from gpytranslate import SyncTranslator
80
 
81
  import logging
 
862
  except Exception as e:
863
  return SuccessResponse(status="False", randydev={"message": str(e)})
864
 
865
+ @app.post("/ryuzaki/blackbox", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
866
+ def blackbox_ai(item: ChatgptCustom):
867
+ try:
868
+ response = send_blackbox_chat(item.query)
869
+ return SuccessResponse(status="True", randydev={"message": response})
870
+ except Exception as e:
871
+ return SuccessResponse(status="False", randydev={"message": str(e)})
872
+
873
  @app.post("/ryuzaki/gemini-ai-pro", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
874
  def gemini_pro(item: GeminiPro):
875
  owner_base = f"""
template.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class Blackbox:
2
+ def __init__(self) -> None:
3
+ """API Class for various purposes"""
4
+ pass
5
+
6
+ @staticmethod
7
+ def chat(args: str) -> dict:
8
+ url = m("aHR0cHM6Ly93d3cuYmxhY2tib3guYWkvYXBpL2NoYXQ=").decode("utf-8")
9
+
10
+ payload = {
11
+ "agentMode": {},
12
+ "codeModelMode": True,
13
+ "id": "XM7KpOE",
14
+ "isMicMode": False,
15
+ "maxTokens": None,
16
+ "messages": [
17
+ {"id": "XM7KpOE", "content": urllib.parse.unquote(args), "role": "user"}
18
+ ],
19
+ "previewToken": None,
20
+ "trendingAgentMode": {},
21
+ "userId": "87cdaa48-cdad-4dda-bef5-6087d6fc72f6",
22
+ "userSystemPrompt": None,
23
+ }
24
+
25
+ headers = {
26
+ "Content-Type": m("YXBwbGljYXRpb24vanNvbg==").decode("utf-8"),
27
+ "Cookie": m("c2Vzc2lvbklkPWY3N2E5MWUxLWNiZTEtNDdkMC1iMTM4LWMyZTIzZWViNWRjZjtpbnRlcmNvbS1pZC1qbG1xeGljYj00Y2YwN2RkOC03NDJlLTRlM2YtODFkZS0zODY2OTgxNmQzMDA7aW50ZXJjb20tZGV2aWNlLWlkLWpsbXF4aWNiPTFlYWZhYWNiLWYxOGQtNDAyYS04MjU1LWI3NjNjZjM5MGRmNjtpbnRlcmNvbS1zZXNzaW9uLWpsbXF4aWNiPQ==").decode("utf-8"),
28
+ "Origin": m("aHR0cHM6Ly93d3cuYmxhY2tib3guYWk=").decode("utf-8"),
29
+ "User-Agent": m("TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCBsaWtlIEdlY2tvKUNocm9tZS8xMjEuMC4wLjAgU2FmYXJpLzUzNy4zNg==").decode("utf-8"),
30
+ }
31
+
32
+ try:
33
+ response = requests.post(url, json=payload, headers=headers)
34
+ response.raise_for_status()
35
+ clean_text = response.text.replace("$@$v=undefined-rv1$@$", "")
36
+
37
+ split_text = clean_text.split("\n\n", 2)
38
+
39
+ if len(split_text) >= 3:
40
+ content_after_second_newline = split_text[2]
41
+ else:
42
+ content_after_second_newline = ""
43
+
44
+ return {"answer": content_after_second_newline, "success": True}
45
+
46
+ except requests.exceptions.RequestException as e:
47
+ return {"results": str(e), "success": False}
48
+
49
+ def send_blackbox_chat(query):
50
+ response = Blackbox.chat(query)
51
+ return response.get("answer")