randydev commited on
Commit
fd36ba6
1 Parent(s): d360c12

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +29 -0
main.py CHANGED
@@ -85,6 +85,8 @@ SOURCE_TIKTOK_WTF_URL = os.environ["SOURCE_TIKTOK_WTF_URL"]
85
  SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
86
  SOURCE_CALLI_GRAPHY_URL = os.environ["SOURCE_CALLI_GRAPHY_URL"]
87
  SOURCE_WHAT_GAY_URL = os.environ["SOURCE_WHAT_GAY_URL"]
 
 
88
 
89
  client_mongo = MongoClient(MONGO_URL)
90
  db = client_mongo["tiktokbot"]
@@ -523,6 +525,33 @@ def free_chatgpt4_bing(query: str):
523
  except:
524
  return {"status": "false", "message": "Error response."}
525
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
  async def get_data(username):
527
  base_msg = ""
528
  async with AsyncClient() as gpx:
 
85
  SOURCE_TIKTOK_TECH_URL = os.environ["SOURCE_TIKTOK_TECH_URL"]
86
  SOURCE_CALLI_GRAPHY_URL = os.environ["SOURCE_CALLI_GRAPHY_URL"]
87
  SOURCE_WHAT_GAY_URL = os.environ["SOURCE_WHAT_GAY_URL"]
88
+ SOURCE_ASSISTANT_GOOGLE_AI = os.environ["SOURCE_ASSISTANT_GOOGLE_AI"]
89
+ ASSISTANT_GOOGLE_API_KEYS = os.environ["ASSISTANT_GOOGLE_API_KEYS"]
90
 
91
  client_mongo = MongoClient(MONGO_URL)
92
  db = client_mongo["tiktokbot"]
 
525
  except:
526
  return {"status": "false", "message": "Error response."}
527
 
528
+ @app.post("/ryuzaki/google-ai")
529
+ def google_ai(query: str, api_key: None = Depends(validate_api_key)):
530
+ url = SOURCE_ASSISTANT_GOOGLE_AI
531
+ token = ASSISTANT_GOOGLE_API_KEYS
532
+ try:
533
+ headers = {"Content-Type": "application/json"}
534
+ data = {
535
+ "prompt": {
536
+ "text": query
537
+ }
538
+ }
539
+ response = requests.post(f"{url}?key={token}", headers=headers, json=data)
540
+ if response.status_code != 200:
541
+ return {"message": f"error {response.status_code}"}
542
+ response_str = response.json()
543
+ answer = response_str["candidates"]
544
+ for results in answer:
545
+ message = results.get("output")
546
+ return {
547
+ "status": "true",
548
+ "randydev":{
549
+ "message": message
550
+ }
551
+ }
552
+ except:
553
+ return {"status": "false", "message": "Error response."}
554
+
555
  async def get_data(username):
556
  base_msg = ""
557
  async with AsyncClient() as gpx: