superdup95 commited on
Commit
f6729bd
1 Parent(s): 442ffab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -2,14 +2,14 @@ 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)
@@ -44,7 +44,7 @@ def get_key_oai_info(key):
44
  key_avai = check_key_availability(session, key)
45
  info_dict = {#"account_name": "",
46
  "key_type": "OpenAI",
47
- "key_availability": True if key_avai else False,
48
  "gpt4_availability": "",
49
  "gpt4_32k_availability": "",
50
  "default_org": "",
@@ -55,22 +55,27 @@ def get_key_oai_info(key):
55
  "tokens_per_minute": "",
56
  #"tokens_per_minute_left": "",
57
  "quota": ""}
58
- if key_avai:
59
- info = get_subscription(key, session, key_avai)
 
 
 
 
 
 
 
 
60
  info_dict["gpt4_availability"] = info["has_gpt4"]
61
  info_dict["gpt4_32k_availability"] = info["has_gpt4_32k"]
62
- info_dict["default_org"] = info["default_org"]
63
- info_dict["org_description"] = info["org_description"]
64
- info_dict["organization"] = info["organization"]
65
  info_dict["models"] = info["models"]
66
  info_dict["requests_per_minute"] = info["rpm"]
67
  info_dict["tokens_per_minute"] = info["tpm"]
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],
@@ -236,6 +241,7 @@ with gr.Blocks() as demo:
236
  with gr.Column():
237
  key = gr.Textbox(lines=1, max_lines=1, label="API Key")
238
  rate_limit = gr.Checkbox(label="Check concurrent rate limit (API Claude) (experimental)")
 
239
  with gr.Row():
240
  clear_button = gr.Button("Clear")
241
  submit_button = gr.Button("Submit", variant="primary")
@@ -243,6 +249,5 @@ with gr.Blocks() as demo:
243
  info = gr.JSON(label="API Key Information")
244
 
245
  clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
246
- submit_button.click(fn=sort_key, inputs=[key, rate_limit], outputs=[info], api_name="sort_key")
247
- demo.launch()
248
- 1
 
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, claude_opus):
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, claude_opus)
13
 
14
  if _key.startswith("sk-"):
15
  return get_key_oai_info(_key)
 
44
  key_avai = check_key_availability(session, key)
45
  info_dict = {#"account_name": "",
46
  "key_type": "OpenAI",
47
+ "key_availability": True if key_avai[0] else False,
48
  "gpt4_availability": "",
49
  "gpt4_32k_availability": "",
50
  "default_org": "",
 
55
  "tokens_per_minute": "",
56
  #"tokens_per_minute_left": "",
57
  "quota": ""}
58
+ if key_avai[0]:
59
+ if key_avai[0] == 200:
60
+ info = get_subscription(key, session, key_avai[1])
61
+ info_dict["default_org"] = info["default_org"]
62
+ info_dict["org_description"] = info["org_description"]
63
+ info_dict["organization"] = info["organization"]
64
+ else:
65
+ empty_org = { 'id': '' }
66
+ info = get_subscription(key, session, [empty_org])
67
+ info_dict["organization"] = key_avai[1]
68
  info_dict["gpt4_availability"] = info["has_gpt4"]
69
  info_dict["gpt4_32k_availability"] = info["has_gpt4_32k"]
 
 
 
70
  info_dict["models"] = info["models"]
71
  info_dict["requests_per_minute"] = info["rpm"]
72
  info_dict["tokens_per_minute"] = info["tpm"]
73
  info_dict["quota"] = info["quota"]
74
  return info_dict
75
 
76
+ async def get_key_ant_info(key, rate_limit, claude_opus):
77
  # Return a dictionary containing key information
78
+ key_avai = check_key_ant_availability(key, claude_opus)
79
  info_dict = {#"account_name": "",
80
  "key_type": "Anthropic Claude",
81
  "key_availability": key_avai[0],
 
241
  with gr.Column():
242
  key = gr.Textbox(lines=1, max_lines=1, label="API Key")
243
  rate_limit = gr.Checkbox(label="Check concurrent rate limit (API Claude) (experimental)")
244
+ claude_opus = gr.Checkbox(label="Use claude-3-opus for filter_response check? (default: claude-3-haiku)")
245
  with gr.Row():
246
  clear_button = gr.Button("Clear")
247
  submit_button = gr.Button("Submit", variant="primary")
 
249
  info = gr.JSON(label="API Key Information")
250
 
251
  clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
252
+ submit_button.click(fn=sort_key, inputs=[key, rate_limit, claude_opus], outputs=[info], api_name="sort_key")
253
+ demo.launch()