Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,7 +151,7 @@ def get_key_gemini_info(key):
|
|
| 151 |
|
| 152 |
def get_key_azure_info(endpoint, api_key):
|
| 153 |
key_avai = check_key_azure_availability(endpoint, api_key)
|
| 154 |
-
info_dict = {
|
| 155 |
"key_type": "Microsoft Azure OpenAI",
|
| 156 |
"key_availability": key_avai[0],
|
| 157 |
"gpt35_availability": "",
|
|
@@ -160,19 +160,42 @@ def get_key_azure_info(endpoint, api_key):
|
|
| 160 |
"dall_e_3_availability": "",
|
| 161 |
"moderation_status": "",
|
| 162 |
"models": "",
|
| 163 |
-
"deployments": ""
|
|
|
|
|
|
|
|
|
|
| 164 |
if key_avai[0]:
|
| 165 |
azure_deploy = get_azure_deploy(endpoint, api_key)
|
| 166 |
status = get_azure_status(endpoint, api_key, azure_deploy)
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
return info_dict
|
| 175 |
|
|
|
|
|
|
|
| 176 |
def get_key_mistral_info(key):
|
| 177 |
key_avai = check_key_mistral_availability(key)
|
| 178 |
info_dict = {#"account_name": "",
|
|
|
|
| 151 |
|
| 152 |
def get_key_azure_info(endpoint, api_key):
|
| 153 |
key_avai = check_key_azure_availability(endpoint, api_key)
|
| 154 |
+
info_dict = {
|
| 155 |
"key_type": "Microsoft Azure OpenAI",
|
| 156 |
"key_availability": key_avai[0],
|
| 157 |
"gpt35_availability": "",
|
|
|
|
| 160 |
"dall_e_3_availability": "",
|
| 161 |
"moderation_status": "",
|
| 162 |
"models": "",
|
| 163 |
+
"deployments": "",
|
| 164 |
+
"rate_limits": {} # New field for per-deployment limits
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
if key_avai[0]:
|
| 168 |
azure_deploy = get_azure_deploy(endpoint, api_key)
|
| 169 |
status = get_azure_status(endpoint, api_key, azure_deploy)
|
| 170 |
+
|
| 171 |
+
# Check rate limits for each deployment
|
| 172 |
+
for model, deployment in azure_deploy.items():
|
| 173 |
+
url = f"https://{endpoint}/openai/deployments/{deployment}/chat/completions?api-version=2024-02-15-preview"
|
| 174 |
+
headers = {"api-key": api_key}
|
| 175 |
+
response = requests.post(url, headers=headers, json={
|
| 176 |
+
"messages": [{"role": "user", "content": "."}],
|
| 177 |
+
"max_tokens": 1
|
| 178 |
+
})
|
| 179 |
+
|
| 180 |
+
info_dict["rate_limits"][model] = {
|
| 181 |
+
"remaining_requests": response.headers.get("x-ratelimit-remaining-requests", ""),
|
| 182 |
+
"remaining_tokens": response.headers.get("x-ratelimit-remaining-tokens", ""),
|
| 183 |
+
"limit_tokens": response.headers.get("x-ratelimit-limit-tokens", "")
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
info_dict.update({
|
| 187 |
+
"gpt35_availability": status[1],
|
| 188 |
+
"gpt4_availability": status[2],
|
| 189 |
+
"gpt4_32k_availability": status[3],
|
| 190 |
+
"dall_e_3_availability": status[4],
|
| 191 |
+
"moderation_status": status[0],
|
| 192 |
+
"models": key_avai[1],
|
| 193 |
+
"deployments": azure_deploy
|
| 194 |
+
})
|
| 195 |
return info_dict
|
| 196 |
|
| 197 |
+
|
| 198 |
+
|
| 199 |
def get_key_mistral_info(key):
|
| 200 |
key_avai = check_key_mistral_availability(key)
|
| 201 |
info_dict = {#"account_name": "",
|