Update app.py
Browse files
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
|
4 |
|
5 |
async def sort_key(key, rate_limit, claude_opus):
|
6 |
_key = key.strip()
|
@@ -32,10 +32,13 @@ async def sort_key(key, rate_limit, claude_opus):
|
|
32 |
|
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 |
return not_supported(_key)
|
40 |
|
41 |
def get_key_oai_info(key):
|
@@ -212,7 +215,20 @@ def get_key_openrouter_info(key):
|
|
212 |
else:
|
213 |
info_dict['usage'] = key_avai[1]
|
214 |
return info_dict
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
def not_supported(key):
|
217 |
info_dict = {#"account_name": "",
|
218 |
"key_type": "Not supported",
|
@@ -224,19 +240,21 @@ def clear_inputs(text):
|
|
224 |
|
225 |
with gr.Blocks() as demo:
|
226 |
gr.Markdown('''
|
227 |
-
# OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter API Key Status Checker
|
228 |
|
229 |
*(Based on shaocongma, CncAnon1, su, Drago, kingbased key checkers)*
|
230 |
|
231 |
AWS credential's format: AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY (root might not be accurate)
|
232 |
|
233 |
Azure endpoint's format: YOUR_RESOURCE_NAME:YOUR_API_KEY or (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY
|
|
|
|
|
234 |
''')
|
235 |
|
236 |
with gr.Row():
|
237 |
with gr.Column():
|
238 |
-
key = gr.Textbox(lines=1, max_lines=
|
239 |
-
rate_limit = gr.Checkbox(label="Check concurrent rate limit (API Claude)
|
240 |
claude_opus = gr.Checkbox(label="Use claude-3-opus for filter_response check? (default: claude-3-haiku)")
|
241 |
with gr.Row():
|
242 |
clear_button = gr.Button("Clear")
|
@@ -246,4 +264,4 @@ with gr.Blocks() as demo:
|
|
246 |
|
247 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
248 |
submit_button.click(fn=sort_key, inputs=[key, rate_limit, claude_opus], outputs=[info], api_name="sort_key")
|
249 |
-
demo.launch()
|
|
|
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()
|
|
|
32 |
|
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 |
|
44 |
def get_key_oai_info(key):
|
|
|
215 |
else:
|
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],
|
224 |
+
"status": "",
|
225 |
+
"enabled_region": ""}
|
226 |
+
if key_avai[0]:
|
227 |
+
info_dict['enabled_region'] = key_avai[2]
|
228 |
+
else:
|
229 |
+
info_dict['status'] = key_avai[1]
|
230 |
+
return info_dict
|
231 |
+
|
232 |
def not_supported(key):
|
233 |
info_dict = {#"account_name": "",
|
234 |
"key_type": "Not supported",
|
|
|
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 |
|
247 |
AWS credential's format: AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY (root might not be accurate)
|
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():
|
255 |
with gr.Column():
|
256 |
+
key = gr.Textbox(lines=1, max_lines=5, label="API Key")
|
257 |
+
rate_limit = gr.Checkbox(label="Check concurrent rate limit (API Claude)")
|
258 |
claude_opus = gr.Checkbox(label="Use claude-3-opus for filter_response check? (default: claude-3-haiku)")
|
259 |
with gr.Row():
|
260 |
clear_button = gr.Button("Clear")
|
|
|
264 |
|
265 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
266 |
submit_button.click(fn=sort_key, inputs=[key, rate_limit, claude_opus], outputs=[info], api_name="sort_key")
|
267 |
+
demo.launch()
|