Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import os
|
|
| 5 |
|
| 6 |
API_URL = "https://host.palple.polrambora.com/pmsq"
|
| 7 |
API_TOKEN = os.getenv("POLLY")
|
| 8 |
-
|
| 9 |
headers = {
|
| 10 |
"authorization":"",
|
| 11 |
"Content-Type": 'application/json',
|
|
@@ -20,7 +20,7 @@ def authorize(api_key):
|
|
| 20 |
"identificator": api_key
|
| 21 |
}
|
| 22 |
test_headers = {
|
| 23 |
-
"authorization":
|
| 24 |
"Content-Type": "application/json",
|
| 25 |
}
|
| 26 |
|
|
@@ -29,7 +29,12 @@ def authorize(api_key):
|
|
| 29 |
print(f"Request Data: {test_data}")
|
| 30 |
print(f"Request Headers: {test_headers}")
|
| 31 |
|
| 32 |
-
response = requests.post(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
print("Request sent!")
|
| 35 |
|
|
@@ -40,10 +45,17 @@ def authorize(api_key):
|
|
| 40 |
else:
|
| 41 |
print(f"Failed request - Status code: {response.status_code}, Response: {response.text}")
|
| 42 |
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
except Exception as e:
|
| 44 |
print(f"Exception occurred: {str(e)}")
|
| 45 |
return False
|
| 46 |
|
|
|
|
| 47 |
def respond(message, history, system_message, max_tokens, top_p, temperature):
|
| 48 |
messages = []
|
| 49 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|
|
|
|
| 5 |
|
| 6 |
API_URL = "https://host.palple.polrambora.com/pmsq"
|
| 7 |
API_TOKEN = os.getenv("POLLY")
|
| 8 |
+
URL_HEADER = os.getenv("KEY")
|
| 9 |
headers = {
|
| 10 |
"authorization":"",
|
| 11 |
"Content-Type": 'application/json',
|
|
|
|
| 20 |
"identificator": api_key
|
| 21 |
}
|
| 22 |
test_headers = {
|
| 23 |
+
"authorization": f"{URL_HEADER}",
|
| 24 |
"Content-Type": "application/json",
|
| 25 |
}
|
| 26 |
|
|
|
|
| 29 |
print(f"Request Data: {test_data}")
|
| 30 |
print(f"Request Headers: {test_headers}")
|
| 31 |
|
| 32 |
+
response = requests.post(
|
| 33 |
+
"https://polrambora.com/api/v2/checkSDPA",
|
| 34 |
+
headers=test_headers,
|
| 35 |
+
data=json.dumps(test_data),
|
| 36 |
+
timeout=10
|
| 37 |
+
)
|
| 38 |
|
| 39 |
print("Request sent!")
|
| 40 |
|
|
|
|
| 45 |
else:
|
| 46 |
print(f"Failed request - Status code: {response.status_code}, Response: {response.text}")
|
| 47 |
return False
|
| 48 |
+
except requests.exceptions.Timeout:
|
| 49 |
+
print("Request timed out")
|
| 50 |
+
return False
|
| 51 |
+
except requests.exceptions.ConnectionError:
|
| 52 |
+
print("Network problem occurred (DNS failure, refused connection, etc.)")
|
| 53 |
+
return False
|
| 54 |
except Exception as e:
|
| 55 |
print(f"Exception occurred: {str(e)}")
|
| 56 |
return False
|
| 57 |
|
| 58 |
+
|
| 59 |
def respond(message, history, system_message, max_tokens, top_p, temperature):
|
| 60 |
messages = []
|
| 61 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|