Update session_id.py
Browse files- session_id.py +18 -14
session_id.py
CHANGED
|
@@ -1,21 +1,25 @@
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
payload = {
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
}
|
| 11 |
|
| 12 |
-
headers = {
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
}
|
| 16 |
|
| 17 |
-
response = requests.post(url, json=payload, headers=headers, timeout=60)
|
| 18 |
-
response.raise_for_status()
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
def generate_chat_session_id():
|
| 5 |
+
url = "https://cloud.onyx.app/api/chat/create-chat-session"
|
| 6 |
|
| 7 |
+
payload = {
|
| 8 |
+
"persona_id": 0,
|
| 9 |
+
"description": "auto session per response",
|
| 10 |
+
"project_id": 123
|
| 11 |
+
}
|
| 12 |
|
| 13 |
+
headers = {
|
| 14 |
+
"Authorization": f"Bearer {os.getenv('PR_KEY')}",
|
| 15 |
+
"Content-Type": "application/json"
|
| 16 |
+
}
|
| 17 |
|
| 18 |
+
response = requests.post(url, json=payload, headers=headers, timeout=60)
|
| 19 |
+
response.raise_for_status()
|
| 20 |
|
| 21 |
+
return response.json()["chat_session_id"]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
print(generate_chat_session_id())
|