superdup95 commited on
Commit
d0281fa
·
verified ·
1 Parent(s): 205ca03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -9
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  import requests, re
3
- from api_usage import get_subscription, check_key_availability, check_key_ant_availability, check_ant_rate_limit, check_key_gemini_availability, check_key_azure_availability, get_azure_status, get_azure_deploy, check_key_mistral_availability, check_mistral_quota, check_key_replicate_availability, check_key_aws_availability, check_key_or_availability, check_key_or_limits, check_gcp_anthropic
4
 
5
  async def sort_key(key, rate_limit, claude_opus):
6
  _key = key.strip()
@@ -16,6 +16,9 @@ async def sort_key(key, rate_limit, claude_opus):
16
 
17
  if _key.startswith("AIzaSy"):
18
  return get_key_gemini_info(_key)
 
 
 
19
 
20
  if (_key.startswith("r8_") and len(_key) == 40) or (_key.islower() and len(_key) == 40):
21
  return get_key_replicate_info(_key)
@@ -33,11 +36,20 @@ async def sort_key(key, rate_limit, claude_opus):
33
  if _key.startswith("AKIA") and len(_key.split(':')[0]) == 20 and _key.split(':')[0].isupper():
34
  return await get_key_aws_info(_key)
35
 
36
- if len(_key) == 32:
 
 
 
37
  return get_key_mistral_info(_key)
38
 
39
- if re.match(re.compile(r"[\w\-]+:[\w\-@\.]+:.+\\n"), _key):
40
- return await get_key_gcp_info(_key)
 
 
 
 
 
 
41
 
42
  return not_supported(_key)
43
 
@@ -106,7 +118,8 @@ def get_key_gemini_info(key):
106
  info_dict = {#"account_name": "",
107
  "key_type": "Google Gemini",
108
  "key_availability": key_avai[0],
109
- "models": key_avai[1]}
 
110
  return info_dict
111
 
112
  def get_key_azure_info(endpoint, api_key):
@@ -117,6 +130,7 @@ def get_key_azure_info(endpoint, api_key):
117
  "gpt35_availability": "",
118
  "gpt4_availability": "",
119
  "gpt4_32k_availability": "",
 
120
  "moderation_status": "",
121
  "models": "",
122
  "deployments": ""}
@@ -126,6 +140,7 @@ def get_key_azure_info(endpoint, api_key):
126
  info_dict["gpt35_availability"] = status[1]
127
  info_dict["gpt4_availability"] = status[2]
128
  info_dict["gpt4_32k_availability"] = status[3]
 
129
  info_dict["moderation_status"] = status[0]
130
  info_dict["models"] = key_avai[1]
131
  info_dict["deployments"] = azure_deploy
@@ -216,8 +231,8 @@ def get_key_openrouter_info(key):
216
  info_dict['usage'] = key_avai[1]
217
  return info_dict
218
 
219
- async def get_key_gcp_info(key):
220
- key_avai = await check_gcp_anthropic(key)
221
  info_dict = {#"account_name": "",
222
  "key_type": "Vertex AI (GCP)",
223
  "key_availability": key_avai[0],
@@ -228,6 +243,31 @@ async def get_key_gcp_info(key):
228
  else:
229
  info_dict['status'] = key_avai[1]
230
  return info_dict
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
  def not_supported(key):
233
  info_dict = {#"account_name": "",
@@ -240,7 +280,7 @@ def clear_inputs(text):
240
 
241
  with gr.Blocks() as demo:
242
  gr.Markdown('''
243
- # OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter/Vertex AI(GCP Anthropic) API Key Status Checker
244
 
245
  *(Based on shaocongma, CncAnon1, su, Drago, kingbased key checkers)*
246
 
@@ -248,7 +288,8 @@ with gr.Blocks() as demo:
248
 
249
  Azure endpoint's format: YOUR_RESOURCE_NAME:YOUR_API_KEY or (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY
250
 
251
- GCP format: PROJECT_ID:CLIENT_EMAIL:PRIVATE_KEY (copy from service account json)
 
252
  ''')
253
 
254
  with gr.Row():
 
1
  import gradio as gr
2
  import requests, re
3
+ from api_usage import get_subscription, check_key_availability, check_key_ant_availability, check_ant_rate_limit, check_key_gemini_availability, check_key_azure_availability, get_azure_status, get_azure_deploy, check_key_mistral_availability, check_mistral_quota, check_key_replicate_availability, check_key_aws_availability, check_key_or_availability, check_key_or_limits, check_gcp_anthropic, check_groq_status, check_nai_status, check_elevenlabs_status
4
 
5
  async def sort_key(key, rate_limit, claude_opus):
6
  _key = key.strip()
 
16
 
17
  if _key.startswith("AIzaSy"):
18
  return get_key_gemini_info(_key)
19
+
20
+ if _key.startswith("pst-"):
21
+ return get_key_nai_info(_key)
22
 
23
  if (_key.startswith("r8_") and len(_key) == 40) or (_key.islower() and len(_key) == 40):
24
  return get_key_replicate_info(_key)
 
36
  if _key.startswith("AKIA") and len(_key.split(':')[0]) == 20 and _key.split(':')[0].isupper():
37
  return await get_key_aws_info(_key)
38
 
39
+ if re.match(re.compile(r"[a-f0-9]{32}"), _key) or re.match(re.compile(r"sk_[a-f0-9]{48}"), _key):
40
+ return get_key_elevenlabs_info(_key)
41
+
42
+ if re.match(re.compile(r"[a-zA-Z0-9]{32}"), _key):
43
  return get_key_mistral_info(_key)
44
 
45
+ if re.match(re.compile(r"gsk_[a-zA-Z0-9]{20}WGdyb3FY[a-zA-Z0-9]{24}"), _key):
46
+ return get_key_groq_info(_key)
47
+
48
+ if re.match(re.compile(r"[\w\-]+:[\w\-@\.]+:[\w-]+:.+"), _key): # 0: refresh token
49
+ return await get_key_gcp_info(_key, 0)
50
+
51
+ if re.match(re.compile(r"[\w\-]+:[\w\-@\.]+:.+\\n"), _key): # 1: service account
52
+ return await get_key_gcp_info(_key, 1)
53
 
54
  return not_supported(_key)
55
 
 
118
  info_dict = {#"account_name": "",
119
  "key_type": "Google Gemini",
120
  "key_availability": key_avai[0],
121
+ "status": key_avai[1],
122
+ "models": key_avai[2]}
123
  return info_dict
124
 
125
  def get_key_azure_info(endpoint, api_key):
 
130
  "gpt35_availability": "",
131
  "gpt4_availability": "",
132
  "gpt4_32k_availability": "",
133
+ "dall_e_3_availability": "",
134
  "moderation_status": "",
135
  "models": "",
136
  "deployments": ""}
 
140
  info_dict["gpt35_availability"] = status[1]
141
  info_dict["gpt4_availability"] = status[2]
142
  info_dict["gpt4_32k_availability"] = status[3]
143
+ info_dict["dall_e_3_availability"] = status[4]
144
  info_dict["moderation_status"] = status[0]
145
  info_dict["models"] = key_avai[1]
146
  info_dict["deployments"] = azure_deploy
 
231
  info_dict['usage'] = key_avai[1]
232
  return info_dict
233
 
234
+ async def get_key_gcp_info(key, type):
235
+ key_avai = await check_gcp_anthropic(key, type)
236
  info_dict = {#"account_name": "",
237
  "key_type": "Vertex AI (GCP)",
238
  "key_availability": key_avai[0],
 
243
  else:
244
  info_dict['status'] = key_avai[1]
245
  return info_dict
246
+
247
+ def get_key_groq_info(key):
248
+ key_avai = check_groq_status(key)
249
+ info_dict = {#"account_name": "",
250
+ "key_type": "Groq",
251
+ "key_availability": True if key_avai else False,
252
+ "models": key_avai if key_avai else ""}
253
+ return info_dict
254
+
255
+ def get_key_nai_info(key):
256
+ key_avai = check_nai_status(key)
257
+ info_dict = {#"account_name": "",
258
+ "key_type": "NovelAI",
259
+ "key_availability": True if key_avai[0] else False,
260
+ "user_info": key_avai[1] if key_avai[0] else ""}
261
+ return info_dict
262
+
263
+ def get_key_elevenlabs_info(key):
264
+ key_avai = check_elevenlabs_status(key)
265
+ info_dict = {#"account_name": "",
266
+ "key_type": "ElevenLabs",
267
+ "key_availability": key_avai[0],
268
+ "user_info": key_avai[1],
269
+ "voices_info": key_avai[2]}
270
+ return info_dict
271
 
272
  def not_supported(key):
273
  info_dict = {#"account_name": "",
 
280
 
281
  with gr.Blocks() as demo:
282
  gr.Markdown('''
283
+ # OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter/Vertex AI(GCP Anthropic)/Groq/NovelAI/ElevenLabs API Key Status Checker
284
 
285
  *(Based on shaocongma, CncAnon1, su, Drago, kingbased key checkers)*
286
 
 
288
 
289
  Azure endpoint's format: YOUR_RESOURCE_NAME:YOUR_API_KEY or (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY
290
 
291
+ GCP format: PROJECT_ID:CLIENT_EMAIL:PRIVATE_KEY (including \\n)
292
+ | or refresh token: PROJECT_ID:CLIENT_ID:CLIENT_SECRET:REFRESH_TOKEN
293
  ''')
294
 
295
  with gr.Row():