Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,10 @@ from api_usage import get_subscription, check_key_availability, check_key_ant_av
|
|
5 |
async def sort_key(key, rate_limit, claude_model):
|
6 |
_key = key.strip()
|
7 |
|
8 |
-
if
|
9 |
return get_key_openrouter_info(_key)
|
10 |
|
11 |
-
if _key.startswith("sk-ant-") and re.match(re.compile("sk-
|
12 |
return await get_key_ant_info(_key, rate_limit, claude_model)
|
13 |
|
14 |
if _key.startswith("sk-"):
|
@@ -226,10 +226,10 @@ def get_key_openrouter_info(key):
|
|
226 |
info_dict['limit'] = key_avai[1]['limit']
|
227 |
info_dict['limit_remaining'] = key_avai[1]['limit_remaining']
|
228 |
info_dict['usage'] = f"${format(key_avai[1]['usage'], '.4f')}"
|
229 |
-
info_dict['balance'] = f"${format(models_info[0], '.4f')}"
|
230 |
info_dict['rate_limit_per_minite'] = key_avai[2]
|
231 |
-
info_dict['4_turbo_per_request_tokens_limit'] = models_info[1]['openai/gpt-
|
232 |
-
info_dict['sonnet_per_request_tokens_limit'] = models_info[1]['anthropic/claude-3-sonnet:beta']
|
233 |
info_dict['opus_per_request_tokens_limit'] = models_info[1]['anthropic/claude-3-opus:beta']
|
234 |
else:
|
235 |
info_dict['usage'] = key_avai[1]
|
@@ -287,7 +287,6 @@ with gr.Blocks() as demo:
|
|
287 |
# OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter/Vertex AI(GCP Anthropic)/Groq/NovelAI/ElevenLabs API Key Status Checker
|
288 |
|
289 |
*(Based on shaocongma, CncAnon1, su, Drago, kingbased key checkers)*
|
290 |
-
|
291 |
AWS credential's format: AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY (root might not be accurate)
|
292 |
|
293 |
Azure endpoint's format: YOUR_RESOURCE_NAME:YOUR_API_KEY or (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY
|
@@ -300,6 +299,8 @@ with gr.Blocks() as demo:
|
|
300 |
'claude-3-sonnet-20240229',
|
301 |
'claude-3-opus-20240229',
|
302 |
'claude-3-5-sonnet-20240620',
|
|
|
|
|
303 |
]
|
304 |
with gr.Row():
|
305 |
with gr.Column():
|
@@ -310,8 +311,8 @@ with gr.Blocks() as demo:
|
|
310 |
clear_button = gr.Button("Clear")
|
311 |
submit_button = gr.Button("Submit", variant="primary")
|
312 |
with gr.Column():
|
313 |
-
info = gr.JSON(label="API Key Information")
|
314 |
|
315 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
316 |
submit_button.click(fn=sort_key, inputs=[key, rate_limit, claude_model], outputs=[info], api_name="sort_key")
|
317 |
-
demo.launch()
|
|
|
5 |
async def sort_key(key, rate_limit, claude_model):
|
6 |
_key = key.strip()
|
7 |
|
8 |
+
if re.match(re.compile("sk-or-v1-[a-z0-9]{64}"), _key):
|
9 |
return get_key_openrouter_info(_key)
|
10 |
|
11 |
+
if re.match(re.compile("sk-ant-api03-[a-zA-Z0-9\-_]{93}AA"), _key) or (_key.startswith("sk-ant-") and len(_key) == 93) or (len(_key) == 89 and re.match(re.compile("sk-[a-zA-Z0-9]{86}"), _key)):
|
12 |
return await get_key_ant_info(_key, rate_limit, claude_model)
|
13 |
|
14 |
if _key.startswith("sk-"):
|
|
|
226 |
info_dict['limit'] = key_avai[1]['limit']
|
227 |
info_dict['limit_remaining'] = key_avai[1]['limit_remaining']
|
228 |
info_dict['usage'] = f"${format(key_avai[1]['usage'], '.4f')}"
|
229 |
+
info_dict['balance'] = f"${format(models_info[0], '.4f')}" if models_info[0] else f"${key_avai[2]/60} (estimated)"
|
230 |
info_dict['rate_limit_per_minite'] = key_avai[2]
|
231 |
+
info_dict['4_turbo_per_request_tokens_limit'] = models_info[1]['openai/gpt-4o']
|
232 |
+
info_dict['sonnet_per_request_tokens_limit'] = models_info[1]['anthropic/claude-3.5-sonnet:beta']
|
233 |
info_dict['opus_per_request_tokens_limit'] = models_info[1]['anthropic/claude-3-opus:beta']
|
234 |
else:
|
235 |
info_dict['usage'] = key_avai[1]
|
|
|
287 |
# OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter/Vertex AI(GCP Anthropic)/Groq/NovelAI/ElevenLabs API Key Status Checker
|
288 |
|
289 |
*(Based on shaocongma, CncAnon1, su, Drago, kingbased key checkers)*
|
|
|
290 |
AWS credential's format: AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY (root might not be accurate)
|
291 |
|
292 |
Azure endpoint's format: YOUR_RESOURCE_NAME:YOUR_API_KEY or (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY
|
|
|
299 |
'claude-3-sonnet-20240229',
|
300 |
'claude-3-opus-20240229',
|
301 |
'claude-3-5-sonnet-20240620',
|
302 |
+
'claude-3-5-sonnet-20241022',
|
303 |
+
'claude-3-5-haiku-20241022'
|
304 |
]
|
305 |
with gr.Row():
|
306 |
with gr.Column():
|
|
|
311 |
clear_button = gr.Button("Clear")
|
312 |
submit_button = gr.Button("Submit", variant="primary")
|
313 |
with gr.Column():
|
314 |
+
info = gr.JSON(label="API Key Information", open=True)
|
315 |
|
316 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
317 |
submit_button.click(fn=sort_key, inputs=[key, rate_limit, claude_model], outputs=[info], api_name="sort_key")
|
318 |
+
demo.launch()
|