Spaces:
Running
Running
Commit
·
45382eb
1
Parent(s):
85cfa8c
Update api_usage.py
Browse files- api_usage.py +11 -36
api_usage.py
CHANGED
@@ -27,42 +27,17 @@ def get_subscription(key):
|
|
27 |
rpm = ""
|
28 |
org = ""
|
29 |
quota = ""
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
quota = "Error: Your account is not active, please check your billing details on our website."
|
42 |
-
else:
|
43 |
-
rpm = "";
|
44 |
-
org = "";
|
45 |
-
quota = f"Unexpected Error at check_key: {error_message}"
|
46 |
-
else:
|
47 |
-
rpm = r.headers['x-ratelimit-limit-requests']
|
48 |
-
org = r.headers['openai-organization']
|
49 |
-
quota = ""
|
50 |
-
|
51 |
-
except Exception as e:
|
52 |
-
error_message = str(e)
|
53 |
-
print(e)
|
54 |
-
if "You exceeded your current quota" in error_message:
|
55 |
-
rpm = "";
|
56 |
-
org = "";
|
57 |
-
quota = "No quota left."
|
58 |
-
elif "Your account is not active" in error_message:
|
59 |
-
rpm = "";
|
60 |
-
org = "";
|
61 |
-
quota = "Error: Your account is not active, please check your billing details on our website."
|
62 |
-
else:
|
63 |
-
rpm = "";
|
64 |
-
org = "";
|
65 |
-
quota = f"Unexpected Error at check_key: {error_message}"
|
66 |
|
67 |
#has_payment_method = results["has_payment_method"]
|
68 |
# hard_limit = results["hard_limit"]
|
|
|
27 |
rpm = ""
|
28 |
org = ""
|
29 |
quota = ""
|
30 |
+
r = requests.post(queryUrl, headers=headers, json=body_gpt4 if check_gpt4_availability() else body_turbo)
|
31 |
+
result = r.json()
|
32 |
+
if (result["error"]):
|
33 |
+
e = result["error"]["code"]
|
34 |
+
rpm = "";
|
35 |
+
org = "";
|
36 |
+
quota = f"Error: {e}"
|
37 |
+
else:
|
38 |
+
rpm = r.headers['x-ratelimit-limit-requests']
|
39 |
+
org = r.headers['openai-organization']
|
40 |
+
quota = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
#has_payment_method = results["has_payment_method"]
|
43 |
# hard_limit = results["hard_limit"]
|