sasaki-saku commited on
Commit
0606965
1 Parent(s): 1e981a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -9
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  import anthropic
3
- from api_usage import get_subscription, check_key_availability, check_key_ant_availability, check_key_gemini_availability, check_key_azure_availability, get_azure_status, get_azure_deploy, check_key_mistral_availability, check_mistral_quota
4
 
5
  def sort_key(key):
6
  _key = key.strip()
@@ -9,7 +9,9 @@ def sort_key(key):
9
  elif _key.startswith("sk-"):
10
  return get_key_oai_info(_key)
11
  elif _key.startswith("AIzaSy"):
12
- return get_key_gemini_info(_key)
 
 
13
  elif len(_key.split(':')) == 2 and _key.split(':')[1].islower() and len(_key.split(':')[1]) == 32 and "openai.azure.com" not in _key.split(':')[1]:
14
  endpoint = f"{_key.split(':')[0]}.openai.azure.com"
15
  api_key = _key.split(':')[1]
@@ -19,9 +21,9 @@ def sort_key(key):
19
  api_key = _key.split(';')[1]
20
  return get_key_azure_info(endpoint, api_key)
21
  elif _key.startswith("AKIA") and len(_key.split(':')[0]) == 20 and _key.split(':')[0].isupper():
22
- return get_key_aws_info(_key)
23
  elif len(_key) == 32:
24
- return get_key_mistral_info(_key)
25
  else:
26
  return not_supported(_key)
27
 
@@ -115,10 +117,38 @@ def get_key_mistral_info(key):
115
  info_dict['has_quota'] = check_mistral_quota(key)
116
  return info_dict
117
 
118
- def get_key_aws_info(key):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  info_dict = {#"account_name": "",
120
  "key_type": "Amazon AWS Claude",
121
- "status": " Soon™ "}
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  return info_dict
123
 
124
  def not_supported(key):
@@ -132,11 +162,13 @@ def clear_inputs(text):
132
 
133
  with gr.Blocks() as demo:
134
  gr.Markdown('''
135
- # OpenAI/Anthropic/Google Gemini/Microsoft Azure/Mistral AI API Key Status Checker
136
 
137
  *(Based on shaocongma, CncAnon1 and Drago key checkers)*
 
 
138
 
139
- Azure endpoint's format: YOUR_RESOURCE_NAME:YOUR_API_KEY or (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY
140
  ''')
141
 
142
  with gr.Row():
@@ -146,7 +178,7 @@ with gr.Blocks() as demo:
146
  clear_button = gr.Button("Clear")
147
  submit_button = gr.Button("Submit", variant="primary")
148
  with gr.Column():
149
- info = gr.JSON(label="OpenAI/Anthropic/Gemini/Azure/Mistral API Key Information")
150
 
151
  clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
152
  submit_button.click(fn=sort_key, inputs=[key], outputs=[info], api_name="sort_key")
 
1
  import gradio as gr
2
  import anthropic
3
+ from api_usage import get_subscription, check_key_availability, check_key_ant_availability, 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
4
 
5
  def sort_key(key):
6
  _key = key.strip()
 
9
  elif _key.startswith("sk-"):
10
  return get_key_oai_info(_key)
11
  elif _key.startswith("AIzaSy"):
12
+ return get_key_gemini_info(_key)
13
+ elif (_key.startswith("r8_") and len(_key) == 40) or (_key.islower() and len(_key) == 40):
14
+ return get_key_replicate_info(_key)
15
  elif len(_key.split(':')) == 2 and _key.split(':')[1].islower() and len(_key.split(':')[1]) == 32 and "openai.azure.com" not in _key.split(':')[1]:
16
  endpoint = f"{_key.split(':')[0]}.openai.azure.com"
17
  api_key = _key.split(':')[1]
 
21
  api_key = _key.split(';')[1]
22
  return get_key_azure_info(endpoint, api_key)
23
  elif _key.startswith("AKIA") and len(_key.split(':')[0]) == 20 and _key.split(':')[0].isupper():
24
+ return get_key_aws_info(_key)
25
  elif len(_key) == 32:
26
+ return get_key_mistral_info(_key)
27
  else:
28
  return not_supported(_key)
29
 
 
117
  info_dict['has_quota'] = check_mistral_quota(key)
118
  return info_dict
119
 
120
+ def get_key_replicate_info(key):
121
+ key_avai = check_key_replicate_availability(key)
122
+ info_dict = {#"account_name": "",
123
+ "key_type": "Replicate",
124
+ "key_availability": key_avai[0],
125
+ "account_name": "",
126
+ "type": "",
127
+ "hardware_available": ""}
128
+ if key_avai[0]:
129
+ info_dict['account_name'] = key_avai[1]['username']
130
+ info_dict['type'] = key_avai[1]['type']
131
+ info_dict['hardware_available'] = key_avai[2]
132
+ return info_dict
133
+
134
+ def get_key_aws_info(key):
135
+ key_avai = check_key_aws_availability(key)
136
  info_dict = {#"account_name": "",
137
  "key_type": "Amazon AWS Claude",
138
+ "key_availability": key_avai[0],
139
+ "username": "",
140
+ "root": "",
141
+ "admin": "",
142
+ "quarantine": "",
143
+ "claude_enabled_region": key_avai[5],
144
+ "cost_and_usage": ""}
145
+ if key_avai[0]:
146
+ info_dict['username'] = key_avai[1]
147
+ info_dict['root'] = key_avai[2]
148
+ info_dict['admin'] = key_avai[3]
149
+ info_dict['quarantine'] = key_avai[4]
150
+ info_dict['claude_enabled_region'] = key_avai[5]
151
+ info_dict['cost_and_usage'] = key_avai[6]
152
  return info_dict
153
 
154
  def not_supported(key):
 
162
 
163
  with gr.Blocks() as demo:
164
  gr.Markdown('''
165
+ # OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude API Key Status Checker
166
 
167
  *(Based on shaocongma, CncAnon1 and Drago key checkers)*
168
+
169
+ AWS credential's format: AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY (root might not be accurate)
170
 
171
+ Azure endpoint's format: YOUR_RESOURCE_NAME:YOUR_API_KEY or (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY
172
  ''')
173
 
174
  with gr.Row():
 
178
  clear_button = gr.Button("Clear")
179
  submit_button = gr.Button("Submit", variant="primary")
180
  with gr.Column():
181
+ info = gr.JSON(label="API Key Information")
182
 
183
  clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
184
  submit_button.click(fn=sort_key, inputs=[key], outputs=[info], api_name="sort_key")