superdup95
commited on
Commit
•
054c5e2
1
Parent(s):
98a0378
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
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, check_key_or_availability, check_key_or_limits
|
4 |
|
5 |
-
def sort_key(key):
|
6 |
_key = key.strip()
|
7 |
|
8 |
if _key.startswith("sk-or-v1-"):
|
9 |
return get_key_openrouter_info(_key)
|
10 |
|
11 |
if _key.startswith("sk-ant-"):
|
12 |
-
return get_key_ant_info(_key)
|
13 |
|
14 |
if _key.startswith("sk-"):
|
15 |
return get_key_oai_info(_key)
|
@@ -68,25 +68,29 @@ def get_key_oai_info(key):
|
|
68 |
info_dict["quota"] = info["quota"]
|
69 |
return info_dict
|
70 |
|
71 |
-
def get_key_ant_info(key):
|
72 |
# Return a dictionary containing key information
|
73 |
key_avai = check_key_ant_availability(key)
|
74 |
info_dict = {#"account_name": "",
|
75 |
"key_type": "Anthropic Claude",
|
76 |
"key_availability": key_avai[0],
|
77 |
-
"status":
|
78 |
-
"filter_response":
|
79 |
-
"requests_per_minute":
|
80 |
-
"tokens_per_minute":
|
81 |
-
"tier":
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
info_dict =
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
90 |
return info_dict
|
91 |
|
92 |
def get_key_gemini_info(key):
|
@@ -225,6 +229,7 @@ with gr.Blocks() as demo:
|
|
225 |
with gr.Row():
|
226 |
with gr.Column():
|
227 |
key = gr.Textbox(lines=1, max_lines=1, label="API Key")
|
|
|
228 |
with gr.Row():
|
229 |
clear_button = gr.Button("Clear")
|
230 |
submit_button = gr.Button("Submit", variant="primary")
|
@@ -232,5 +237,5 @@ with gr.Blocks() as demo:
|
|
232 |
info = gr.JSON(label="API Key Information")
|
233 |
|
234 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
235 |
-
submit_button.click(fn=sort_key, inputs=[key], outputs=[info], api_name="sort_key")
|
236 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
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):
|
6 |
_key = key.strip()
|
7 |
|
8 |
if _key.startswith("sk-or-v1-"):
|
9 |
return get_key_openrouter_info(_key)
|
10 |
|
11 |
if _key.startswith("sk-ant-"):
|
12 |
+
return await get_key_ant_info(_key, rate_limit)
|
13 |
|
14 |
if _key.startswith("sk-"):
|
15 |
return get_key_oai_info(_key)
|
|
|
68 |
info_dict["quota"] = info["quota"]
|
69 |
return info_dict
|
70 |
|
71 |
+
async def get_key_ant_info(key, rate_limit):
|
72 |
# Return a dictionary containing key information
|
73 |
key_avai = check_key_ant_availability(key)
|
74 |
info_dict = {#"account_name": "",
|
75 |
"key_type": "Anthropic Claude",
|
76 |
"key_availability": key_avai[0],
|
77 |
+
"status": "",
|
78 |
+
"filter_response": "",
|
79 |
+
"requests_per_minute": "",
|
80 |
+
"tokens_per_minute": "",
|
81 |
+
"tier": "",
|
82 |
+
"concurrent_rate_limit": ""}
|
83 |
+
|
84 |
+
info_dict["status"] = key_avai[1]
|
85 |
+
info_dict["filter_response"] = key_avai[2]
|
86 |
+
info_dict["requests_per_minute"] = key_avai[3] + ("" if key_avai[3] == "" else f" ({key_avai[4]} left)")
|
87 |
+
info_dict["tokens_per_minute"] = key_avai[5] + ("" if key_avai[5] == "" else f" ({key_avai[6]} left)")
|
88 |
+
info_dict["tier"] = key_avai[7]
|
89 |
+
|
90 |
+
if rate_limit:
|
91 |
+
rate = await check_ant_rate_limit(key)
|
92 |
+
info_dict["concurrent_rate_limit"] = rate
|
93 |
+
|
94 |
return info_dict
|
95 |
|
96 |
def get_key_gemini_info(key):
|
|
|
229 |
with gr.Row():
|
230 |
with gr.Column():
|
231 |
key = gr.Textbox(lines=1, max_lines=1, label="API Key")
|
232 |
+
rate_limit = gr.Checkbox(label="Check concurrent rate limit (API Claude) (experimental)")
|
233 |
with gr.Row():
|
234 |
clear_button = gr.Button("Clear")
|
235 |
submit_button = gr.Button("Submit", variant="primary")
|
|
|
237 |
info = gr.JSON(label="API Key Information")
|
238 |
|
239 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
240 |
+
submit_button.click(fn=sort_key, inputs=[key, rate_limit], outputs=[info], api_name="sort_key")
|
241 |
demo.launch()
|