Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,17 +15,30 @@ ASSISTANT_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/reso
|
|
| 15 |
USER_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/resolve/main/usr.png"
|
| 16 |
|
| 17 |
def authorize(api_key):
|
| 18 |
-
test_data = {
|
|
|
|
|
|
|
|
|
|
| 19 |
test_headers = {
|
| 20 |
-
"Authorization": f"{API_TOKEN}",
|
| 21 |
"Content-Type": "application/json",
|
| 22 |
}
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
return False
|
| 30 |
|
| 31 |
def respond(message, history, system_message, max_tokens, top_p, temperature):
|
|
|
|
| 15 |
USER_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/resolve/main/usr.png"
|
| 16 |
|
| 17 |
def authorize(api_key):
|
| 18 |
+
test_data = {
|
| 19 |
+
"kind": "PER_DATA",
|
| 20 |
+
"identificator": api_key
|
| 21 |
+
}
|
| 22 |
test_headers = {
|
| 23 |
+
"Authorization": f"{API_TOKEN}",
|
| 24 |
"Content-Type": "application/json",
|
| 25 |
}
|
| 26 |
+
|
| 27 |
+
try:
|
| 28 |
+
response = requests.post("https://polrambora.com/api/v2/checkSDPA", headers=test_headers, data=json.dumps(test_data))
|
| 29 |
+
|
| 30 |
+
if response.status_code == 200:
|
| 31 |
+
response_json = response.json()
|
| 32 |
+
if "identificator" in response_json:
|
| 33 |
+
return True
|
| 34 |
+
else:
|
| 35 |
+
print("Authorization failed: 'identificator' not found in response.")
|
| 36 |
+
return False
|
| 37 |
+
else:
|
| 38 |
+
print(f"Error: {response.status_code} - {response.text}")
|
| 39 |
+
return False
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f"Exception occurred: {str(e)}")
|
| 42 |
return False
|
| 43 |
|
| 44 |
def respond(message, history, system_message, max_tokens, top_p, temperature):
|