randydev commited on
Commit
ae6eb7d
1 Parent(s): f0a24e7

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +28 -16
main.py CHANGED
@@ -472,6 +472,12 @@ def ocr_space_url(
472
 
473
  @app.get("/ryuzaki/nochatgpt", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
474
  def no_chatgpt(query: str=None):
 
 
 
 
 
 
475
  try:
476
  url = "http://216.98.10.228:5000"
477
  api_method = f"{url}/gpt?ask={query}"
@@ -479,10 +485,10 @@ def no_chatgpt(query: str=None):
479
  if response.status_code != 200:
480
  return SuccessResponse(status="False", randydev={"message": f"Error response"})
481
  return SuccessResponse(status="True", randydev={"message": response.text})
482
- except requests.exceptions.ConnectTimeout as e:
483
- return SuccessResponse(status="False", randydev={"message": f"Error response: {e}"})
484
  except Exception as e:
485
- return SuccessResponse(status="False", randydev={"message": f"Error response: {e}"})
486
 
487
  @app.get("/ryuzaki/freechatgpt-beta", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
488
  def free_chatgpt4_beta(item: ChatgptCustom):
@@ -657,29 +663,29 @@ def image_unsplash(item: GetImageUnsplash):
657
 
658
  @app.post("/ryuzaki/chatgpt-model", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
659
  def chatgpt_model(item: ChatgptModel):
 
 
 
 
 
 
660
  url = "https://lexica.qewertyy.me/models"
661
  if item.is_models:
662
  params = {"model_id": item.model_id, "prompt": item.query}
663
  response = requests.post(url, params=params)
664
  if response.status_code != 200:
665
- return f"Error status: {response.status_code}"
666
  check_response = response.json()
667
  answer = check_response.get("content")
668
- return SuccessResponse(
669
- status="True",
670
- randydev={"message": answer}
671
- )
672
  else:
673
  params = {"model_id": 5, "prompt": item.query}
674
  response = requests.post(url, params=params)
675
  if response.status_code != 200:
676
- return f"Error status: {response.status_code}"
677
  check_response = response.json()
678
  answer = check_response.get("content")
679
- return SuccessResponse(
680
- status="True",
681
- randydev={"message": answer}
682
- )
683
 
684
  @app.post("/ryuzaki/chatgpt3-turbo", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
685
  def chatgpt3_turbo(
@@ -781,6 +787,12 @@ def gemini_pro(item: GeminiPro):
781
 
782
  Today is {dt.now():%A %d %B %Y %H:%M}
783
  """
 
 
 
 
 
 
784
  if item.is_multi_chat:
785
  selected_api_key = ASSISTANT_GOOGLE_API_KEYS or item.gemini_api_key
786
  try:
@@ -793,8 +805,8 @@ def gemini_pro(item: GeminiPro):
793
  "chat_history": gemini_chat
794
  }
795
  )
796
- except Exception as e:
797
- return SuccessResponse(status="False", randydev={"message": f"Error not responding: {e}"})
798
  else:
799
  if item.is_login:
800
  token = item.bard_api_key
@@ -816,7 +828,7 @@ def gemini_pro(item: GeminiPro):
816
  message = bard.get_answer(item.query)["content"]
817
  return SuccessResponse(status="True", randydev={"message": message})
818
  except:
819
- return SuccessResponse(status="False", randydev={"message": "Error not responding"})
820
 
821
  @app.post("/ryuzaki/v1beta2-google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
822
  def v1beta2_google_ai(
 
472
 
473
  @app.get("/ryuzaki/nochatgpt", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
474
  def no_chatgpt(query: str=None):
475
+ contact_support = """
476
+ We are aware that AI is currently offline. This seems to be caused by the API
477
+ We are investigating and doing our best to get things back online as soon as possible. Thank you for your patience
478
+
479
+ Contact Support @xtdevs
480
+ """
481
  try:
482
  url = "http://216.98.10.228:5000"
483
  api_method = f"{url}/gpt?ask={query}"
 
485
  if response.status_code != 200:
486
  return SuccessResponse(status="False", randydev={"message": f"Error response"})
487
  return SuccessResponse(status="True", randydev={"message": response.text})
488
+ except requests.exceptions.ConnectTimeout:
489
+ return SuccessResponse(status="False", randydev={"message": contact_support})
490
  except Exception as e:
491
+ return SuccessResponse(status="False", randydev={"message": contact_support})
492
 
493
  @app.get("/ryuzaki/freechatgpt-beta", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
494
  def free_chatgpt4_beta(item: ChatgptCustom):
 
663
 
664
  @app.post("/ryuzaki/chatgpt-model", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
665
  def chatgpt_model(item: ChatgptModel):
666
+ contact_support = """
667
+ We are aware that AI is currently offline. This seems to be caused by the API
668
+ We are investigating and doing our best to get things back online as soon as possible. Thank you for your patience
669
+
670
+ Contact Support @xtdevs
671
+ """
672
  url = "https://lexica.qewertyy.me/models"
673
  if item.is_models:
674
  params = {"model_id": item.model_id, "prompt": item.query}
675
  response = requests.post(url, params=params)
676
  if response.status_code != 200:
677
+ return SuccessResponse(status="False", randydev={"message": contact_support})
678
  check_response = response.json()
679
  answer = check_response.get("content")
680
+ return SuccessResponse(status="True", randydev={"message": answer})
 
 
 
681
  else:
682
  params = {"model_id": 5, "prompt": item.query}
683
  response = requests.post(url, params=params)
684
  if response.status_code != 200:
685
+ return SuccessResponse(status="False", randydev={"message": contact_support})
686
  check_response = response.json()
687
  answer = check_response.get("content")
688
+ return SuccessResponse(status="True", randydev={"message": answer})
 
 
 
689
 
690
  @app.post("/ryuzaki/chatgpt3-turbo", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
691
  def chatgpt3_turbo(
 
787
 
788
  Today is {dt.now():%A %d %B %Y %H:%M}
789
  """
790
+ contact_support = """
791
+ We are aware that AI is currently offline. This seems to be caused by the API
792
+ We are investigating and doing our best to get things back online as soon as possible. Thank you for your patience
793
+
794
+ Contact Support @xtdevs
795
+ """
796
  if item.is_multi_chat:
797
  selected_api_key = ASSISTANT_GOOGLE_API_KEYS or item.gemini_api_key
798
  try:
 
805
  "chat_history": gemini_chat
806
  }
807
  )
808
+ except Exception:
809
+ return SuccessResponse(status="False", randydev={"message": contact_support})
810
  else:
811
  if item.is_login:
812
  token = item.bard_api_key
 
828
  message = bard.get_answer(item.query)["content"]
829
  return SuccessResponse(status="True", randydev={"message": message})
830
  except:
831
+ return SuccessResponse(status="False", randydev={"message": contact_support})
832
 
833
  @app.post("/ryuzaki/v1beta2-google-ai", response_model=SuccessResponse, responses={422: {"model": ErrorStatus}})
834
  def v1beta2_google_ai(