Update app.py
Browse files
app.py
CHANGED
|
@@ -10,8 +10,7 @@ app = Flask(__name__)
|
|
| 10 |
# -------------------------------------------------------------------
|
| 11 |
GLOBAL_WORKSPACE_ID = "wkspace_01JVCT7SCHHQBH0PTCQNTF6TYF"
|
| 12 |
GLOBAL_BOT_ID = "5d89e4f7-c1bd-4238-92c4-e4188e74fd49"
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
# -------------------------------------------------------------------
|
| 17 |
# Helper functions for random bot/workspace names
|
|
@@ -27,7 +26,7 @@ def create_workspace():
|
|
| 27 |
ws_url = "https://api.botpress.cloud/v1/admin/workspaces"
|
| 28 |
headers = {
|
| 29 |
"User-Agent": "Mozilla/5.0",
|
| 30 |
-
"
|
| 31 |
}
|
| 32 |
payload = {"name": generate_random_name()}
|
| 33 |
response = requests.post(ws_url, headers=headers, json=payload)
|
|
@@ -45,7 +44,7 @@ def create_bot(workspace_id):
|
|
| 45 |
headers = {
|
| 46 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 47 |
"x-workspace-id": workspace_id,
|
| 48 |
-
"
|
| 49 |
}
|
| 50 |
payload = {"name": generate_random_name()}
|
| 51 |
response = requests.post(bot_url, headers=headers, json=payload)
|
|
@@ -66,7 +65,7 @@ def delete_bot(bot_id, workspace_id):
|
|
| 66 |
headers = {
|
| 67 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 68 |
"x-workspace-id": workspace_id,
|
| 69 |
-
"
|
| 70 |
}
|
| 71 |
return requests.delete(url, headers=headers)
|
| 72 |
|
|
@@ -75,7 +74,7 @@ def delete_workspace(workspace_id):
|
|
| 75 |
url = f"https://api.botpress.cloud/v1/admin/workspaces/{workspace_id}"
|
| 76 |
headers = {
|
| 77 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 78 |
-
"
|
| 79 |
}
|
| 80 |
return requests.delete(url, headers=headers)
|
| 81 |
|
|
@@ -93,7 +92,7 @@ def chat_with_assistant(user_input, image_url, bot_id, workspace_id):
|
|
| 93 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 94 |
"x-bot-id": bot_id, # existing bot ID (could be None on first try)
|
| 95 |
"Content-Type": "application/json",
|
| 96 |
-
"
|
| 97 |
}
|
| 98 |
|
| 99 |
# Prepare the payload
|
|
|
|
| 10 |
# -------------------------------------------------------------------
|
| 11 |
GLOBAL_WORKSPACE_ID = "wkspace_01JVCT7SCHHQBH0PTCQNTF6TYF"
|
| 12 |
GLOBAL_BOT_ID = "5d89e4f7-c1bd-4238-92c4-e4188e74fd49"
|
| 13 |
+
TOKEN = "Bearer bp_pat_vTuxol25N0ymBpYaWqtWpFfGPKt260IfT784"
|
|
|
|
| 14 |
|
| 15 |
# -------------------------------------------------------------------
|
| 16 |
# Helper functions for random bot/workspace names
|
|
|
|
| 26 |
ws_url = "https://api.botpress.cloud/v1/admin/workspaces"
|
| 27 |
headers = {
|
| 28 |
"User-Agent": "Mozilla/5.0",
|
| 29 |
+
"Authorization": TOKEN
|
| 30 |
}
|
| 31 |
payload = {"name": generate_random_name()}
|
| 32 |
response = requests.post(ws_url, headers=headers, json=payload)
|
|
|
|
| 44 |
headers = {
|
| 45 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 46 |
"x-workspace-id": workspace_id,
|
| 47 |
+
"Authorization": TOKEN
|
| 48 |
}
|
| 49 |
payload = {"name": generate_random_name()}
|
| 50 |
response = requests.post(bot_url, headers=headers, json=payload)
|
|
|
|
| 65 |
headers = {
|
| 66 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 67 |
"x-workspace-id": workspace_id,
|
| 68 |
+
"Authorization": TOKEN
|
| 69 |
}
|
| 70 |
return requests.delete(url, headers=headers)
|
| 71 |
|
|
|
|
| 74 |
url = f"https://api.botpress.cloud/v1/admin/workspaces/{workspace_id}"
|
| 75 |
headers = {
|
| 76 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 77 |
+
"Authorization": TOKEN
|
| 78 |
}
|
| 79 |
return requests.delete(url, headers=headers)
|
| 80 |
|
|
|
|
| 92 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 93 |
"x-bot-id": bot_id, # existing bot ID (could be None on first try)
|
| 94 |
"Content-Type": "application/json",
|
| 95 |
+
"Authorization": TOKEN
|
| 96 |
}
|
| 97 |
|
| 98 |
# Prepare the payload
|