sasaki-saku
commited on
Commit
•
a0bd21f
1
Parent(s):
6bdd5a2
Add Gemini/Azure
Browse files
app.py
CHANGED
@@ -1,18 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
import anthropic
|
3 |
-
from api_usage import get_subscription, check_key_availability, check_key_ant_availability
|
4 |
|
5 |
def sort_key(key):
|
6 |
_key = key.strip()
|
7 |
if _key.startswith("sk-ant-"):
|
8 |
return get_key_ant_info(_key)
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
else:
|
10 |
return get_key_oai_info(_key)
|
11 |
|
12 |
def get_key_oai_info(key):
|
13 |
# Return a dictionary containing key information
|
14 |
key_avai = check_key_availability(key)
|
15 |
-
info_dict = {"account_name": "",
|
|
|
16 |
"key_availability": True if key_avai else False,
|
17 |
"gpt4_availability": "",
|
18 |
"gpt4_32k_availability": "",
|
@@ -40,31 +47,72 @@ def get_key_oai_info(key):
|
|
40 |
def get_key_ant_info(key):
|
41 |
# Return a dictionary containing key information
|
42 |
ant = anthropic.Anthropic(api_key=key)
|
43 |
-
|
44 |
-
info_dict = {"account_name": "",
|
45 |
-
"
|
46 |
-
"
|
47 |
-
"
|
|
|
48 |
return info_dict
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def clear_inputs(text):
|
51 |
return ""
|
52 |
|
53 |
with gr.Blocks() as demo:
|
54 |
gr.Markdown('''
|
55 |
-
# OpenAI/Anthropic API Key Status Checker
|
|
|
|
|
56 |
|
57 |
-
|
58 |
''')
|
59 |
|
60 |
with gr.Row():
|
61 |
with gr.Column():
|
62 |
-
key =
|
63 |
with gr.Row():
|
64 |
clear_button = gr.Button("Clear")
|
65 |
submit_button = gr.Button("Submit", variant="primary")
|
66 |
with gr.Column():
|
67 |
-
info = gr.JSON(label="OpenAI/Anthropic API Key Information")
|
68 |
|
69 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
70 |
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
|
4 |
|
5 |
def sort_key(key):
|
6 |
_key = key.strip()
|
7 |
if _key.startswith("sk-ant-"):
|
8 |
return get_key_ant_info(_key)
|
9 |
+
elif _key.startswith("AIzaSy"):
|
10 |
+
return get_key_gemini_info(_key)
|
11 |
+
elif "openai.azure.com" in _key.split(';')[0]:
|
12 |
+
return get_key_azure_info(_key)
|
13 |
+
elif _key.startswith("AKIA"):
|
14 |
+
return get_key_aws_info(_key)
|
15 |
else:
|
16 |
return get_key_oai_info(_key)
|
17 |
|
18 |
def get_key_oai_info(key):
|
19 |
# Return a dictionary containing key information
|
20 |
key_avai = check_key_availability(key)
|
21 |
+
info_dict = {#"account_name": "",
|
22 |
+
"key_type": "OpenAI",
|
23 |
"key_availability": True if key_avai else False,
|
24 |
"gpt4_availability": "",
|
25 |
"gpt4_32k_availability": "",
|
|
|
47 |
def get_key_ant_info(key):
|
48 |
# Return a dictionary containing key information
|
49 |
ant = anthropic.Anthropic(api_key=key)
|
50 |
+
key_avai = check_key_ant_availability(ant)
|
51 |
+
info_dict = {#"account_name": "",
|
52 |
+
"key_type": "Anthropic Claude",
|
53 |
+
"key_availability": key_avai[0],
|
54 |
+
"status": key_avai[1],
|
55 |
+
"filter_response": key_avai[2]}
|
56 |
return info_dict
|
57 |
|
58 |
+
def get_key_gemini_info(key):
|
59 |
+
key_avai = check_key_gemini_availability(key)
|
60 |
+
info_dict = {#"account_name": "",
|
61 |
+
"key_type": "Google Gemini",
|
62 |
+
"key_availability": key_avai[0],
|
63 |
+
"models": key_avai[1]}
|
64 |
+
return info_dict
|
65 |
+
|
66 |
+
def get_key_azure_info(key):
|
67 |
+
key_avai = check_key_azure_availability(key)
|
68 |
+
if key_avai[0]:
|
69 |
+
azure_deploy = get_azure_deploy(key)
|
70 |
+
status = get_azure_status(key, azure_deploy)
|
71 |
+
info_dict = {#"account_name": "",
|
72 |
+
"key_type": "Microsoft Azure OpenAI",
|
73 |
+
"key_availability": key_avai[0],
|
74 |
+
"gpt4_32k_availability": status[1],
|
75 |
+
"gpt4_turbo_availability": status[2],
|
76 |
+
"gpt4_availability": status[3],
|
77 |
+
"gpt35_availability": status[4],
|
78 |
+
"models": key_avai[1],
|
79 |
+
"deployments": azure_deploy,
|
80 |
+
"moderation_response": status[0]}
|
81 |
+
else:
|
82 |
+
info_dict = {#"account_name": "",
|
83 |
+
"key_type": "Microsoft Azure OpenAI",
|
84 |
+
"key_availability": False,
|
85 |
+
"models": None,
|
86 |
+
"deployments": None,
|
87 |
+
"moderation_response": ""}
|
88 |
+
return info_dict
|
89 |
+
|
90 |
+
def get_key_aws_info(key):
|
91 |
+
info_dict = {#"account_name": "",
|
92 |
+
"key_type": "Amazon AWS Claude",
|
93 |
+
"status": " Soon™ "}
|
94 |
+
return info_dict
|
95 |
+
|
96 |
def clear_inputs(text):
|
97 |
return ""
|
98 |
|
99 |
with gr.Blocks() as demo:
|
100 |
gr.Markdown('''
|
101 |
+
# OpenAI/Anthropic/Google Gemini/Microsoft Azure API Key Status Checker
|
102 |
+
|
103 |
+
*(Based on shaocongma, CncAnon1 and Drago key checkers)*
|
104 |
|
105 |
+
(Azure endpoint's format: (https://)YOUR_RESOURCE_NAME.openai.azure.com;YOUR_API_KEY)
|
106 |
''')
|
107 |
|
108 |
with gr.Row():
|
109 |
with gr.Column():
|
110 |
+
key = gr.Textbox(lines=1, max_lines=1, label="OpenAI/Anthropic/Gemini/Azure API Key")
|
111 |
with gr.Row():
|
112 |
clear_button = gr.Button("Clear")
|
113 |
submit_button = gr.Button("Submit", variant="primary")
|
114 |
with gr.Column():
|
115 |
+
info = gr.JSON(label="OpenAI/Anthropic/Gemini/Azure API Key Information")
|
116 |
|
117 |
clear_button.click(fn=clear_inputs, inputs=[key], outputs=[key])
|
118 |
submit_button.click(fn=sort_key, inputs=[key], outputs=[info], api_name="sort_key")
|