Commit
·
e7dbcf0
1
Parent(s):
5381b58
Update api_usage.py
Browse files- api_usage.py +4 -4
api_usage.py
CHANGED
|
@@ -25,15 +25,15 @@ def get_subscription(key):
|
|
| 25 |
gpt4_avai = check_gpt4_availability()
|
| 26 |
|
| 27 |
if check_key_availability():
|
| 28 |
-
rpm =
|
| 29 |
org = ""
|
| 30 |
quota = ""
|
| 31 |
r = requests.post(queryUrl, headers=headers, json=body_gpt4 if gpt4_avai else body_turbo)
|
| 32 |
result = r.json()
|
| 33 |
if "id" in result:
|
| 34 |
-
rpm =
|
| 35 |
org = r.headers['openai-organization']
|
| 36 |
-
quota = check_key_type("gpt-4" if gpt4_avai else "gpt-3.5-turbo", rpm)
|
| 37 |
else:
|
| 38 |
e = result["error"]["code"]
|
| 39 |
quota = f"Error: {e}"
|
|
@@ -66,7 +66,7 @@ def check_key_type(model, rpm):
|
|
| 66 |
elif rpm == rate_limit_per_model[model]:
|
| 67 |
return "yes | pay"
|
| 68 |
else:
|
| 69 |
-
return "yes | pay, possibly big key
|
| 70 |
|
| 71 |
def check_gpt4_availability():
|
| 72 |
if check_key_availability():
|
|
|
|
| 25 |
gpt4_avai = check_gpt4_availability()
|
| 26 |
|
| 27 |
if check_key_availability():
|
| 28 |
+
rpm = ""
|
| 29 |
org = ""
|
| 30 |
quota = ""
|
| 31 |
r = requests.post(queryUrl, headers=headers, json=body_gpt4 if gpt4_avai else body_turbo)
|
| 32 |
result = r.json()
|
| 33 |
if "id" in result:
|
| 34 |
+
rpm = r.headers['x-ratelimit-limit-requests']
|
| 35 |
org = r.headers['openai-organization']
|
| 36 |
+
quota = check_key_type("gpt-4" if gpt4_avai else "gpt-3.5-turbo", int(rpm))
|
| 37 |
else:
|
| 38 |
e = result["error"]["code"]
|
| 39 |
quota = f"Error: {e}"
|
|
|
|
| 66 |
elif rpm == rate_limit_per_model[model]:
|
| 67 |
return "yes | pay"
|
| 68 |
else:
|
| 69 |
+
return "yes | pay, possibly big key"
|
| 70 |
|
| 71 |
def check_gpt4_availability():
|
| 72 |
if check_key_availability():
|