randydev commited on
Commit
d8c5ebf
1 Parent(s): 8b04fd1

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +31 -1
main.py CHANGED
@@ -102,6 +102,7 @@ SOURCE_ASSISTANT_GOOGLE_AI = os.environ["SOURCE_ASSISTANT_GOOGLE_AI"]
102
  SOURCE_MONITOR_URL = os.environ["SOURCE_MONITOR_URL"]
103
  SOURCE_OPENAI_ACCESS_URL = os.environ["SOURCE_OPENAI_ACCESS_URL"]
104
  SOURCE_PICSART_URL = os.environ["SOURCE_PICSART_URL"]
 
105
 
106
  # api keys
107
  REVERSE_IMAGE_API = os.environ["REVERSE_IMAGE_API"]
@@ -509,6 +510,35 @@ def no_chatgpt(query: str=None):
509
  except Exception as e:
510
  return SuccessResponse(status="False", randydev={"message": contact_support})
511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  @app.get("/ryuzaki/freechatgpt-beta", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
513
  def free_chatgpt4_beta(item: ChatgptCustom):
514
  try:
@@ -1433,4 +1463,4 @@ def custom_openapi():
1433
 
1434
  app.openapi = custom_openapi
1435
 
1436
- app.add_exception_handler(HTTPException, custom_exception_handler)
 
102
  SOURCE_MONITOR_URL = os.environ["SOURCE_MONITOR_URL"]
103
  SOURCE_OPENAI_ACCESS_URL = os.environ["SOURCE_OPENAI_ACCESS_URL"]
104
  SOURCE_PICSART_URL = os.environ["SOURCE_PICSART_URL"]
105
+ SOURCE_CHATGPT_OLD_URL = os.environ["SOURCE_CHATGPT_OLD_URL"]
106
 
107
  # api keys
108
  REVERSE_IMAGE_API = os.environ["REVERSE_IMAGE_API"]
 
510
  except Exception as e:
511
  return SuccessResponse(status="False", randydev={"message": contact_support})
512
 
513
+ @app.post("/ryuzaki/chatgpt-old", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
514
+ def chatgpt_olds(query: str=None):
515
+ headers = {
516
+ "Accept": "application/json",
517
+ "Content-Type": "application/json",
518
+ "Accept-Language": "en",
519
+ "Connection": "keep-alive",
520
+ "Origin": "https://remix.ethereum.org",
521
+ "Referer": "https://remix.ethereum.org/",
522
+ "Sec-Fetch-Dest": "empty",
523
+ "Sec-Fetch-Mode": "cors",
524
+ "Sec-Fetch-Site": "cross-site",
525
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"
526
+ }
527
+ payload = {"prompt": query}
528
+ try:
529
+ url = SOURCE_CHATGPT_OLD_URL
530
+ response = requests.post(url, data=json.dumps(payload), headers=headers, timeout=50000)
531
+ if response.status_code != 200:
532
+ return SuccessResponse(status="False", randydev={"message": contact_support})
533
+ body = ""
534
+ for i in response.json()["choices"]:
535
+ body += i["message"]["content"]
536
+ return SuccessResponse(status="True", randydev={"message": body})
537
+ except requests.exceptions.ConnectTimeout:
538
+ return SuccessResponse(status="False", randydev={"message": contact_support})
539
+ except Exception as e:
540
+ return SuccessResponse(status="False", randydev={"message": contact_support})
541
+
542
  @app.get("/ryuzaki/freechatgpt-beta", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
543
  def free_chatgpt4_beta(item: ChatgptCustom):
544
  try:
 
1463
 
1464
  app.openapi = custom_openapi
1465
 
1466
+ app.add_exception_handler(HTTPException, custom_exception_handler)