fudii0921 commited on
Commit
c840751
·
verified ·
1 Parent(s): 59a2556

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -1
app.py CHANGED
@@ -14,9 +14,42 @@ import numpy as np
14
  from PIL import Image as PILImage
15
  import base64
16
  from io import BytesIO
 
17
 
18
  # Set the base directory
19
- BASE_DIR = os.getcwd()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  GROQ_API_KEY = os.environ.get('GROQ_API_KEY')
22
 
 
14
  from PIL import Image as PILImage
15
  import base64
16
  from io import BytesIO
17
+ import mysql.connector
18
 
19
  # Set the base directory
20
+ #BASE_DIR = os.getcwd()
21
+ # MySQLに接続
22
+ conn = mysql.connector.connect(
23
+ host="www.ryhintl.com",
24
+ user="smairuser",
25
+ password="smairuser",
26
+ port=36000,
27
+ database="smair"
28
+ )
29
+
30
+ cursor = conn.cursor(dictionary=True)
31
+
32
+ def get_api_keys():
33
+ select_one_data_query = "SELECT * FROM agentic_apis_copy where api = 'GROQ_KEYS'"
34
+ cursor.execute(select_one_data_query)
35
+ result = cursor.fetchall()
36
+ keys = [item['key'] for item in result]
37
+ rtnkey = ",".join(map(str, keys))
38
+
39
+ return rtnkey
40
+
41
+ # List of Groq tokens
42
+ mytokens = get_api_keys()
43
+
44
+ tokens = eval("["+mytokens+"]")
45
+
46
+ def get_next_token():
47
+ token = tokens[random.randint(0, len(tokens) - 1)]
48
+ return token
49
+
50
+ token = get_next_token()
51
+
52
+ os.environ["GROQ_API_KEY"] = token
53
 
54
  GROQ_API_KEY = os.environ.get('GROQ_API_KEY')
55