Update Bsb
Browse files
Bsb
CHANGED
|
@@ -1,660 +1,847 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
#
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
#
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
}
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
""
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
effort_name = effort["name"]
|
| 197 |
-
files = effort["files"] if effort["files"] else []
|
| 198 |
-
permission_json = effort["permission"]
|
| 199 |
-
effort_permissions = []
|
| 200 |
-
|
| 201 |
-
if "can_view_effort" not in effort_permissions:
|
| 202 |
-
effort_permissions.append("can_view_effort")
|
| 203 |
-
permissions["efforts"].append({"name": effort_name, "id": effort_id})
|
| 204 |
-
permissions["files"][effort_id] = files
|
| 205 |
-
|
| 206 |
-
cursor.execute("SELECT notebook_id, notebook_name FROM notebook_details WHERE effort_id=%s", (effort_id,))
|
| 207 |
-
notebook_details = cursor.fetchall()
|
| 208 |
-
permissions["notebooks"][effort_id] = [{"name": note["notebook_name"], "id": note["notebook_id"]} for note in notebook_details]
|
| 209 |
-
|
| 210 |
-
cursor.execute("SELECT id, name FROM zones WHERE effort_id=%s", (effort_id,))
|
| 211 |
-
zones = cursor.fetchall()
|
| 212 |
-
permissions["ezones"][effort_id] = [{"name": zone["name"], "id": zone["id"]} for zone in zones]
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
if "can_create_zones" not in effort_permissions:
|
| 216 |
-
effort_permissions.append("can_create_zones")
|
| 217 |
-
if "can_modify_zones" not in effort_permissions:
|
| 218 |
-
effort_permissions.append("can_modify_zones")
|
| 219 |
-
if "can_delete_zones" not in effort_permissions:
|
| 220 |
-
effort_permissions.append("can_delete_zones")
|
| 221 |
-
|
| 222 |
-
if "can_create_notebooks" not in effort_permissions:
|
| 223 |
-
effort_permissions.append("can_create_notebooks")
|
| 224 |
-
if "can_delete_notebooks" not in effort_permissions:
|
| 225 |
-
effort_permissions.append("can_delete_notebooks")
|
| 226 |
-
|
| 227 |
-
if effort_permissions:
|
| 228 |
-
permissions["permissions"].append({effort_id: effort_permissions})
|
| 229 |
-
|
| 230 |
-
else:
|
| 231 |
-
permissions["permissions"].append("can_view_efforts")
|
| 232 |
-
|
| 233 |
-
cursor.execute("SELECT id, effort_id, name, config FROM zones")
|
| 234 |
-
zone_data = cursor.fetchall()
|
| 235 |
-
|
| 236 |
-
effort_id_to_name = {effort["id"]: effort["name"] for effort in efforts_data}
|
| 237 |
-
|
| 238 |
-
for zone in zone_data:
|
| 239 |
-
zone_id = zone["id"]
|
| 240 |
-
zone_name = zone["name"]
|
| 241 |
-
zone_effort = zone["effort_id"]
|
| 242 |
-
zone_config = zone["config"]
|
| 243 |
-
|
| 244 |
-
zone_effort_name = effort_id_to_name.get(zone_effort, "Unknown Effort")
|
| 245 |
-
|
| 246 |
-
if zone_config["is_global"]:
|
| 247 |
-
permissions["global_ezones"].append({"name": zone_name, "id": zone_id, "effort_id": zone_effort, "effort_name": zone_effort_name})
|
| 248 |
-
|
| 249 |
-
for effort in efforts_data:
|
| 250 |
-
|
| 251 |
-
effort_id = effort["id"]
|
| 252 |
-
effort_name = effort["name"]
|
| 253 |
-
files = effort["files"] if effort["files"] else []
|
| 254 |
-
permission_json = effort["permission"]
|
| 255 |
-
effort_permissions = []
|
| 256 |
-
|
| 257 |
-
"""
|
| 258 |
-
if ad_group in permission_json.get("can_create_zones", []):
|
| 259 |
-
effort_permissions.append("can_create_zones")
|
| 260 |
-
if ad_group in permission_json.get("can_modify_zones", []):
|
| 261 |
-
effort_permissions.append("can_modify_zones")
|
| 262 |
-
if ad_group in permission_json.get("can_delete_zones", []):
|
| 263 |
-
effort_permissions.append("can_delete_zones")
|
| 264 |
-
if ad_group in permission_json.get("can_create_notebooks", []):
|
| 265 |
-
effort_permissions.append("can_create_notebooks")
|
| 266 |
-
if ad_group in permission_json.get("can_delete_notebooks", []):
|
| 267 |
-
effort_permissions.append("can_delete_notebooks")
|
| 268 |
-
"""
|
| 269 |
-
|
| 270 |
-
for ad_group in ad_groups:
|
| 271 |
-
|
| 272 |
-
if ad_group in permission_json.get("can_view_effort", []):
|
| 273 |
-
if "can_view_effort" not in effort_permissions:
|
| 274 |
-
effort_permissions.append("can_view_effort")
|
| 275 |
-
permissions["efforts"].append({"name": effort_name, "id": effort_id})
|
| 276 |
-
permissions["files"][effort_id] = files
|
| 277 |
-
|
| 278 |
-
cursor.execute("SELECT notebook_id, notebook_name FROM notebook_details WHERE effort_id=%s", (effort_id,))
|
| 279 |
-
notebook_details = cursor.fetchall()
|
| 280 |
-
permissions["notebooks"][effort_id] = [{"name": note["notebook_name"], "id": note["notebook_id"]} for note in notebook_details]
|
| 281 |
-
|
| 282 |
-
cursor.execute("SELECT id, name FROM zones WHERE effort_id=%s", (effort_id,))
|
| 283 |
-
zones = cursor.fetchall()
|
| 284 |
-
permissions["ezones"][effort_id] = [{"name": zone["name"], "id": zone["id"]} for zone in zones]
|
| 285 |
-
|
| 286 |
-
if ad_group in permission_json.get("can_create_and_modify_zones", []):
|
| 287 |
-
if "can_create_zones" not in effort_permissions:
|
| 288 |
-
effort_permissions.append("can_create_zones")
|
| 289 |
-
if "can_modify_zones" not in effort_permissions:
|
| 290 |
-
effort_permissions.append("can_modify_zones")
|
| 291 |
-
if "can_delete_zones" not in effort_permissions:
|
| 292 |
-
effort_permissions.append("can_delete_zones")
|
| 293 |
-
|
| 294 |
-
if ad_group in permission_json.get("can_create_and_modify_notebooks", []):
|
| 295 |
-
if "can_create_notebooks" not in effort_permissions:
|
| 296 |
-
effort_permissions.append("can_create_notebooks")
|
| 297 |
-
if "can_delete_notebooks" not in effort_permissions:
|
| 298 |
-
effort_permissions.append("can_delete_notebooks")
|
| 299 |
-
|
| 300 |
-
if effort_permissions:
|
| 301 |
-
permissions["permissions"].append({effort_id: effort_permissions})
|
| 302 |
-
|
| 303 |
-
return {
|
| 304 |
-
"permissions": permissions["permissions"],
|
| 305 |
-
"efforts": permissions["efforts"],
|
| 306 |
-
"notebooks": permissions["notebooks"],
|
| 307 |
-
"ezones": permissions["ezones"],
|
| 308 |
-
"global_ezones": permissions["global_ezones"],
|
| 309 |
-
"files": permissions["files"]
|
| 310 |
}
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
}
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
}
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
cursor = conn.cursor()
|
| 528 |
-
if not name:
|
| 529 |
-
raise HTTPException(status_code=400, detail="Zone name cannot be empty")
|
| 530 |
-
|
| 531 |
-
cursor.execute("SELECT effort_id FROM zones WHERE id = %s", (zone_id,))
|
| 532 |
-
|
| 533 |
-
if cursor.rowcount == 0:
|
| 534 |
-
raise ValueError(f"Experiment zone with ID {zone_id} not found")
|
| 535 |
-
|
| 536 |
-
effort_id = cursor.fetchone()[0]
|
| 537 |
-
|
| 538 |
-
config = {
|
| 539 |
-
"llm_model": llm_model,
|
| 540 |
-
"embedding_model": embedding_model,
|
| 541 |
-
"vector_db": vector_db,
|
| 542 |
-
"chunking_strategy": chunking_strategy,
|
| 543 |
-
"indexer": indexer,
|
| 544 |
-
"top_k": top_k,
|
| 545 |
-
"overlap": overlap,
|
| 546 |
-
"chunk_size": chunk_size,
|
| 547 |
-
"description": description,
|
| 548 |
-
"is_global": is_global
|
| 549 |
}
|
| 550 |
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
)
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
return{"rating": result[0], "comment": result[1]}
|
| 657 |
-
return None
|
| 658 |
-
except Exception as e:
|
| 659 |
-
logger.error(f"Error retriving feedback: {str(e)}")
|
| 660 |
-
return None
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
| 6 |
+
<title>Chat Interface</title>
|
| 7 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
| 10 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 11 |
+
<style>
|
| 12 |
+
/* Unified CSS for Chat, EffortsHomePage, and NotebookPage */
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
background-color: #f5f8fc;
|
| 16 |
+
color: #1a1a1a;
|
| 17 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 18 |
+
padding-bottom: 4rem;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.bg-gradient-to-r {
|
| 22 |
+
background: linear-gradient(90deg, #4f46e5, #3b82f6) !important;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.text-white {
|
| 26 |
+
color: #fff !important;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.card.card-item,
|
| 30 |
+
.w-1\/4.bg-white,
|
| 31 |
+
.w-3\/4.bg-white {
|
| 32 |
+
background-color: #ffffff !important;
|
| 33 |
+
border: 1px solid #d0d7e2 !important;
|
| 34 |
+
color: #1a1a1a;
|
| 35 |
+
border-radius: 10px !important;
|
| 36 |
+
box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important;
|
| 37 |
+
padding: 1rem 1.5rem !important;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.shadow-md, .shadow {
|
| 41 |
+
box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.rounded-2xl, .rounded-lg {
|
| 45 |
+
border-radius: 10px !important;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
#chat-box {
|
| 49 |
+
background: #f8f9fc !important;
|
| 50 |
+
border: 1px solid #d0d7e2 !important;
|
| 51 |
+
border-radius: 10px !important;
|
| 52 |
+
color: #1a1a1a;
|
| 53 |
+
height: 26rem;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
input.form-control, .form-control, select.form-control,
|
| 57 |
+
#persona, #message, #summary-type {
|
| 58 |
+
background: #f8f9fc !important;
|
| 59 |
+
color: #1a1a1a !important;
|
| 60 |
+
border: 1px solid #d0d7e2 !important;
|
| 61 |
+
border-radius: 6px !important;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
input.form-control::placeholder, .form-control::placeholder,
|
| 65 |
+
#persona::placeholder, #message::placeholder {
|
| 66 |
+
color: #9aa5bc !important;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.btn-gradient, .upload-button, .submit-btn, .bg-blue-600, .bg-green-600 {
|
| 70 |
+
background: linear-gradient(90deg, #4f46e5, #3b82f6) !important;
|
| 71 |
+
color: white !important;
|
| 72 |
+
border: none !important;
|
| 73 |
+
border-radius: 8px !important;
|
| 74 |
+
font-weight: 600;
|
| 75 |
+
transition: background 0.2s;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.btn-gradient:hover, .upload-button:hover, .submit-btn:hover, .bg-blue-700, .bg-green-700 {
|
| 79 |
+
background: linear-gradient(90deg, #4338ca, #2563eb) !important;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.btn-danger, .btn-outline-danger {
|
| 83 |
+
background-color: #d9534f !important;
|
| 84 |
+
color: white !important;
|
| 85 |
+
border: none !important;
|
| 86 |
+
border-radius: 8px !important;
|
| 87 |
+
font-weight: 600;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.btn-danger:hover, .btn-outline-danger:hover {
|
| 91 |
+
background-color: #c9302c !important;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
#file-list > li {
|
| 95 |
+
border-radius: 10px !important;
|
| 96 |
+
border: 1px solid #d0d7e2 !important;
|
| 97 |
+
background: #fff !important;
|
| 98 |
+
box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important;
|
| 99 |
+
padding: 1rem 1.5rem !important;
|
| 100 |
+
margin-bottom: 1rem !important;
|
| 101 |
+
transition: box-shadow 0.2s, border-color 0.2s;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
#file-list > li:hover {
|
| 105 |
+
border-color: #a0b4e3 !important;
|
| 106 |
+
background-color: #f0f4ff !important;
|
| 107 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06) !important;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.loading-dots {
|
| 111 |
+
display: inline-block;
|
| 112 |
+
text-align: left;
|
| 113 |
+
}
|
| 114 |
+
.loading-dots span {
|
| 115 |
+
display: inline-block;
|
| 116 |
+
width: 8px;
|
| 117 |
+
height: 8px;
|
| 118 |
+
margin: 0 2px;
|
| 119 |
+
background-color: #555;
|
| 120 |
+
border-radius: 50%;
|
| 121 |
+
animation: blink 1.4s infinite both;
|
| 122 |
+
}
|
| 123 |
+
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
|
| 124 |
+
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
|
| 125 |
+
@keyframes blink {
|
| 126 |
+
0%, 80%, 100% { opacity: 0; }
|
| 127 |
+
40% { opacity: 1; }
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
#uploadModal .modal-content,
|
| 131 |
+
.modal-content {
|
| 132 |
+
background: #ffffff !important;
|
| 133 |
+
color: #1a1a1a;
|
| 134 |
+
border-radius: 12px !important;
|
| 135 |
+
border: 1px solid #d0d7e2 !important;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
#uploadModal .drop-zone {
|
| 139 |
+
border-radius: 10px !important;
|
| 140 |
+
border: 2px dashed #d0d7e2 !important;
|
| 141 |
+
background: #f8f9fc !important;
|
| 142 |
+
color: #9aa5bc !important;
|
| 143 |
+
transition: border-color 0.2s, color 0.2s;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
#uploadModal .drop-zone:hover, #uploadModal .drop-zone.border-blue-500 {
|
| 147 |
+
border-color: #4f46e5 !important;
|
| 148 |
+
color: #4f46e5 !important;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
#effort-path, #notebook-path, #file-path {
|
| 152 |
+
font-size: 1rem;
|
| 153 |
+
font-weight: 600;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
@media (max-width: 900px) {
|
| 157 |
+
.w-1\/4, .w-3\/4 {
|
| 158 |
+
width: 100% !important;
|
| 159 |
+
display: block !important;
|
| 160 |
+
}
|
| 161 |
+
.flex {
|
| 162 |
+
flex-direction: column !important;
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/* Header Styles */
|
| 167 |
+
.chat-header {
|
| 168 |
+
background: #fff;
|
| 169 |
+
border-radius: 12px;
|
| 170 |
+
box-shadow: 0 1px 4px rgba(0,0,0,0.05);
|
| 171 |
+
padding: 1.25rem 2rem;
|
| 172 |
+
display: flex;
|
| 173 |
+
justify-content: space-between;
|
| 174 |
+
align-items: center;
|
| 175 |
+
margin-bottom: 2rem;
|
| 176 |
+
border: 1px solid #d0d7e2;
|
| 177 |
+
}
|
| 178 |
+
.chat-header-title {
|
| 179 |
+
font-size: 1.75rem; /* Matches h2 in your other HTML files */
|
| 180 |
+
background: linear-gradient(90deg, #4f46e5, #3b82f6);
|
| 181 |
+
background-clip: text;
|
| 182 |
+
-webkit-background-clip: text;
|
| 183 |
+
-webkit-text-fill-color: transparent;
|
| 184 |
+
}
|
| 185 |
+
.chat-header .no-style {
|
| 186 |
+
background: none;
|
| 187 |
+
background-clip: initial;
|
| 188 |
+
-webkit-background-clip: initial;
|
| 189 |
+
-webkit-text-fill-color: initial;
|
| 190 |
+
color: inherit;
|
| 191 |
+
}
|
| 192 |
+
</style>
|
| 193 |
+
</head>
|
| 194 |
+
<body class="font-sans">
|
| 195 |
+
|
| 196 |
+
<!-- Header -->
|
| 197 |
+
<div class="chat-header container-title mb-4">
|
| 198 |
+
<div class="d-flex align-items-center gap-3">
|
| 199 |
+
<button
|
| 200 |
+
onclick="window.location.href='/notebook/?effort_id={{ effort_id }}&user_id={{ user_id }}'"
|
| 201 |
+
id = "backBtn"
|
| 202 |
+
class="btn btn-outline-primary"
|
| 203 |
+
aria-label="Go back"
|
| 204 |
+
style="padding: 0.375rem 0.75rem;"
|
| 205 |
+
>
|
| 206 |
+
<i class="bi bi-arrow-left"></i>
|
| 207 |
+
</button>
|
| 208 |
+
<h2 class="fw-bold mb-0 chat-header-title">
|
| 209 |
+
<span class="no-style">📚</span> Document Chat & Summarization
|
| 210 |
+
</h2>
|
| 211 |
+
</div>
|
| 212 |
+
<div class="position-relative" style="min-width: 14rem;">
|
| 213 |
+
<select id="zone-dropdown"
|
| 214 |
+
class="form-control bg-white text-dark shadow-sm"
|
| 215 |
+
style="padding-right: 2.5rem;">
|
| 216 |
+
</select>
|
| 217 |
+
<span class="position-absolute top-50 end-0 translate-middle-y pe-3">
|
| 218 |
+
<svg class="w-4 h-4 text-secondary" fill="none" stroke="currentColor" stroke-width="2"
|
| 219 |
+
viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" style="width: 1.25rem; height: 1.25rem;">
|
| 220 |
+
<polyline points="6 9 12 15 18 9"></polyline>
|
| 221 |
+
</svg>
|
| 222 |
+
</span>
|
| 223 |
+
</div>
|
| 224 |
+
</div>
|
| 225 |
+
|
| 226 |
+
<!-- Directory Path Display -->
|
| 227 |
+
<div class="max-w-7xl mx-auto mt-6 px-4 text-gray-700 text-sm font-medium select-none">
|
| 228 |
+
<span id="effort-path" class="text-gray-800 font-semibold">{{ effort_name }}</span>
|
| 229 |
+
<span class="mx-2 text-gray-500">→</span>
|
| 230 |
+
<span id="notebook-path" class="text-gray-800 font-semibold">{{ notebook_name }}</span>
|
| 231 |
+
<span class="mx-2 text-gray-500">→</span>
|
| 232 |
+
<span id="file-path" class="text-blue-700 font-semibold">No File Selected</span>
|
| 233 |
+
</div>
|
| 234 |
+
|
| 235 |
+
<!-- Main Layout -->
|
| 236 |
+
<div class="flex max-w-7xl mx-auto mt-6 gap-6 px-4">
|
| 237 |
+
<!-- LEFT: Sidebar -->
|
| 238 |
+
<div class="w-1/4 bg-white rounded-2xl shadow-md p-4 h-[34rem] overflow-y-auto">
|
| 239 |
+
<button class="upload-button w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded mb-4"
|
| 240 |
+
onclick="openModal()">Upload File(s)</button>
|
| 241 |
+
<h3 class="text-lg font-semibold mb-2 text-gray-700">📂 Available Files</h3>
|
| 242 |
+
<ul id="file-list" class="space-y-3 text-gray-700 text-sm">
|
| 243 |
+
<!-- Files injected here -->
|
| 244 |
+
</ul>
|
| 245 |
+
</div>
|
| 246 |
+
|
| 247 |
+
<!-- RIGHT: Chat Panel -->
|
| 248 |
+
<div class="w-3/4 bg-white rounded-2xl shadow-md p-6 flex flex-col">
|
| 249 |
+
<div id="chat-box" class="overflow-y-scroll border rounded-lg p-4 bg-gray-50 space-y-3 mb-4">
|
| 250 |
+
<!-- Chat messages will appear here -->
|
| 251 |
+
</div>
|
| 252 |
+
|
| 253 |
+
<div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-2 mt-auto">
|
| 254 |
+
<input id="persona" type="text" placeholder="Enter persona..." value="You are a helpful assistant"
|
| 255 |
+
class="px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500" />
|
| 256 |
+
|
| 257 |
+
<input id="message" type="text" placeholder="Type your message..."
|
| 258 |
+
class="flex-grow px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" />
|
| 259 |
+
|
| 260 |
+
<button onclick="sendMessage()"
|
| 261 |
+
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition">
|
| 262 |
+
Send
|
| 263 |
+
</button>
|
| 264 |
+
|
| 265 |
+
<select id="summary-type"
|
| 266 |
+
class="px-3 py-2 border rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-green-500">
|
| 267 |
+
<option value="brief">Brief</option>
|
| 268 |
+
<option value="detailed">Detailed</option>
|
| 269 |
+
</select>
|
| 270 |
+
|
| 271 |
+
<button onclick="summarize()"
|
| 272 |
+
class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-lg transition">
|
| 273 |
+
Summarize
|
| 274 |
+
</button>
|
| 275 |
+
</div>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
|
| 279 |
+
<!-- Upload Modal -->
|
| 280 |
+
<div id="uploadModal" class="modal fixed z-50 inset-0 hidden bg-black bg-opacity-50 flex justify-center items-center">
|
| 281 |
+
<div class="modal-content bg-white p-6 rounded-xl w-[90%] max-w-md relative">
|
| 282 |
+
<span class="close absolute top-3 right-4 text-xl cursor-pointer" onclick="closeModal()">×</span>
|
| 283 |
+
<h2 class="text-xl font-bold text-gray-800">NotebookLM</h2>
|
| 284 |
+
<p class="text-sm text-gray-600 mt-1">Add sources (PDF only)</p>
|
| 285 |
+
<div id="dropZone" class="drop-zone mt-4 border-2 border-dashed border-gray-300 p-6 rounded-lg text-gray-500 text-sm text-center cursor-pointer hover:border-blue-500 hover:text-blue-500"
|
| 286 |
+
onclick="triggerFileInput()">Drag & drop or <u>choose files</u><br><small>Supported: PDF</small></div>
|
| 287 |
+
<input type="file" id="fileInput" accept=".pdf" multiple class="hidden" />
|
| 288 |
+
<div id="selectedFilesList" class="mt-4 text-gray-700 text-sm space-y-1 max-h-40 overflow-y-auto">
|
| 289 |
+
<!-- File names shown here -->
|
| 290 |
+
</div>
|
| 291 |
+
<div class="flex justify-center mt-4">
|
| 292 |
+
<button class="submit-btn bg-blue-600 text-white px-4 py-2 rounded" onclick="submitFile()">Upload</button>
|
| 293 |
+
</div>
|
| 294 |
+
</div>
|
| 295 |
+
</div>
|
| 296 |
+
|
| 297 |
+
<!-- Delete File Confirmation Modal -->
|
| 298 |
+
<div class="modal fade" id="deleteFileModal" tabindex="-1" aria-labelledby="deleteFileModalLabel" aria-hidden="true">
|
| 299 |
+
<div class="modal-dialog">
|
| 300 |
+
<div class="modal-content">
|
| 301 |
+
<div class="modal-header">
|
| 302 |
+
<h5 class="modal-title" id="deleteFileModalLabel">Confirm Delete</h5>
|
| 303 |
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
| 304 |
+
</div>
|
| 305 |
+
<div class="modal-body">
|
| 306 |
+
Are you sure you want to delete <strong id="deleteFileName"></strong>?
|
| 307 |
+
</div>
|
| 308 |
+
<div class="modal-footer">
|
| 309 |
+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
| 310 |
+
<button type="button" class="btn btn-danger" onclick="confirmDeleteFile()">Delete</button>
|
| 311 |
+
</div>
|
| 312 |
+
</div>
|
| 313 |
+
</div>
|
| 314 |
+
</div>
|
| 315 |
+
<!-- FEEDBACK MODAL (Bootstrap) -->
|
| 316 |
+
<div class="modal fade" id="feedbackModal" tabindex="-1" aria-labelledby="feedbackModalLabel" aria-hidden="true">
|
| 317 |
+
<div class="modal-dialog" role="document">
|
| 318 |
+
<div class="modal-content" style="background-color: white; color: black;">
|
| 319 |
+
<div class="modal-header">
|
| 320 |
+
<h5 class="modal-title" id="feedbackModalLabel">Rate Your Experience</h5>
|
| 321 |
+
<!-- Proper Bootstrap “close” button -->
|
| 322 |
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
| 323 |
+
</div>
|
| 324 |
+
<div class="modal-body">
|
| 325 |
+
<label for="feedbackLevel">Rating (optional):</label>
|
| 326 |
+
<select id="feedbackLevel" class="form-control">
|
| 327 |
+
<option value="">-- Select --</option>
|
| 328 |
+
<option value="1">Very Bad</option>
|
| 329 |
+
<option value="2">Bad</option>
|
| 330 |
+
<option value="3">Neutral</option>
|
| 331 |
+
<option value="4">Good</option>
|
| 332 |
+
<option value="5">Very Good</option>
|
| 333 |
+
</select>
|
| 334 |
+
|
| 335 |
+
<label for="comment" class="mt-2">Comments (optional):</label>
|
| 336 |
+
<textarea id="comment" class="form-control" rows="3" placeholder="Write your feedback here..."></textarea>
|
| 337 |
+
<div id ="updateNotice" class = "text-secondary mt-2" style="display:none;font-size:0.9em;">
|
| 338 |
+
(Your Previously Submitted Feedback. You can update it if needed.)
|
| 339 |
+
</div>
|
| 340 |
+
</div>
|
| 341 |
+
<div class="modal-footer">
|
| 342 |
+
<button id="submitFeedback" class="btn btn-primary">Submit</button>
|
| 343 |
+
<button id="skipFeedback" type="button" class="btn btn-secondary">Skip</button>
|
| 344 |
+
</div>
|
| 345 |
+
</div>
|
| 346 |
+
</div>
|
| 347 |
+
</div>
|
| 348 |
+
|
| 349 |
+
<script>
|
| 350 |
+
const userId = "{{ user_id }}";
|
| 351 |
+
const effortId = "{{ effort_id }}";
|
| 352 |
+
const notebookId = "{{ notebook_id }}"
|
| 353 |
+
const effortName = "{{ effort_name }}";
|
| 354 |
+
const notebookName = "{{ notebook_name}}"
|
| 355 |
+
const preloadedFiles = {{ files | tojson }};
|
| 356 |
+
const preloadedZones = {{ zones | tojson }};
|
| 357 |
+
const globalZones = {{ global_ezones | tojson }};
|
| 358 |
+
const chatHistory = {{ chat_history | tojson }};
|
| 359 |
+
const chatBox = document.getElementById("chat-box");
|
| 360 |
+
const zoneDropdown = document.getElementById("zone-dropdown");
|
| 361 |
+
const fileList = document.getElementById("file-list");
|
| 362 |
+
const modal = document.getElementById("uploadModal");
|
| 363 |
+
const fileInput = document.getElementById("fileInput");
|
| 364 |
+
|
| 365 |
+
//Feedback modal -----
|
| 366 |
+
const backButton = document.getElementById("backBtn");
|
| 367 |
+
const feedbackModalEl = document.getElementById("feedbackModal");
|
| 368 |
+
const bootstrapFeedbackModal = new bootstrap.Modal(feedbackModalEl);
|
| 369 |
+
|
| 370 |
+
fileInput.addEventListener("change", () => {
|
| 371 |
+
const list = document.getElementById("selectedFilesList");
|
| 372 |
+
list.innerHTML = "";
|
| 373 |
+
|
| 374 |
+
const files = fileInput.files;
|
| 375 |
+
if (!files.length) {
|
| 376 |
+
list.textContent = "No files selected.";
|
| 377 |
+
return;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
for (let file of files) {
|
| 381 |
+
const item = document.createElement("div");
|
| 382 |
+
item.className = "flex items-center gap-2";
|
| 383 |
+
item.innerHTML = `📄 <span class="truncate">${file.name}</span>`;
|
| 384 |
+
list.appendChild(item);
|
| 385 |
+
}
|
| 386 |
+
});
|
| 387 |
+
|
| 388 |
+
let currentZoneId = null;
|
| 389 |
+
let currentFileUri = "";
|
| 390 |
+
let selectedFileElement = null;
|
| 391 |
+
|
| 392 |
+
function appendMessage(sender, message, color, alignRight = false) {
|
| 393 |
+
const wrapper = document.createElement("div");
|
| 394 |
+
wrapper.className = alignRight ? "flex justify-end" : "flex justify-start";
|
| 395 |
+
|
| 396 |
+
const bubble = document.createElement("div");
|
| 397 |
+
bubble.className = `max-w-xl px-4 py-2 rounded-lg ${color} text-white`;
|
| 398 |
+
|
| 399 |
+
// Use <pre> tag to preserve formatting in the message
|
| 400 |
+
bubble.innerHTML = `<strong>${sender}:</strong><br><pre class="whitespace-pre-wrap break-words">${message}</pre>`;
|
| 401 |
+
|
| 402 |
+
wrapper.appendChild(bubble);
|
| 403 |
+
chatBox.appendChild(wrapper);
|
| 404 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
function loadZones() {
|
| 408 |
+
zoneDropdown.innerHTML = "";
|
| 409 |
+
const defaultOpt = document.createElement("option");
|
| 410 |
+
defaultOpt.disabled = true;
|
| 411 |
+
defaultOpt.selected = true;
|
| 412 |
+
defaultOpt.textContent = "Select a Configuration";
|
| 413 |
+
zoneDropdown.appendChild(defaultOpt);
|
| 414 |
+
|
| 415 |
+
try {
|
| 416 |
+
const addedZoneIds = new Set();
|
| 417 |
+
|
| 418 |
+
preloadedZones.forEach(zone => {
|
| 419 |
+
if (!addedZoneIds.has(zone.id)) {
|
| 420 |
+
const opt = document.createElement("option");
|
| 421 |
+
opt.value = zone.id;
|
| 422 |
+
opt.textContent = zone.name;
|
| 423 |
+
zoneDropdown.appendChild(opt);
|
| 424 |
+
addedZoneIds.add(zone.id);
|
| 425 |
+
}
|
| 426 |
+
});
|
| 427 |
+
|
| 428 |
+
globalZones.forEach(zone => {
|
| 429 |
+
if (!addedZoneIds.has(zone.id)) {
|
| 430 |
+
const opt = document.createElement("option");
|
| 431 |
+
opt.value = zone.id;
|
| 432 |
+
opt.textContent = zone.name + " (Global)";
|
| 433 |
+
zoneDropdown.appendChild(opt);
|
| 434 |
+
addedZoneIds.add(zone.id);
|
| 435 |
+
}
|
| 436 |
+
});
|
| 437 |
+
|
| 438 |
+
const divider = document.createElement("option");
|
| 439 |
+
divider.disabled = true;
|
| 440 |
+
divider.textContent = "──────────";
|
| 441 |
+
zoneDropdown.appendChild(divider);
|
| 442 |
+
} catch (err) {
|
| 443 |
+
console.error("Error loading zones:", err);
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
const manage = document.createElement("option");
|
| 447 |
+
manage.value = "manage";
|
| 448 |
+
manage.textContent = "➕ Manage Configurations";
|
| 449 |
+
zoneDropdown.appendChild(manage);
|
| 450 |
+
|
| 451 |
+
zoneDropdown.addEventListener("change", (e) => {
|
| 452 |
+
if (e.target.value === "manage") {
|
| 453 |
+
const form = document.createElement("form");
|
| 454 |
+
form.method = "POST";
|
| 455 |
+
form.action = "/chat_feature/manage_zones";
|
| 456 |
+
|
| 457 |
+
const userInput = document.createElement("input");
|
| 458 |
+
userInput.type = "hidden";
|
| 459 |
+
userInput.name = "user_id";
|
| 460 |
+
userInput.value = userId;
|
| 461 |
+
form.appendChild(userInput);
|
| 462 |
+
|
| 463 |
+
const effortInput = document.createElement("input");
|
| 464 |
+
effortInput.type = "hidden";
|
| 465 |
+
effortInput.name = "effort_id";
|
| 466 |
+
effortInput.value = effortId;
|
| 467 |
+
form.appendChild(effortInput);
|
| 468 |
+
|
| 469 |
+
const notebookInput = document.createElement("input");
|
| 470 |
+
notebookInput.type = "hidden";
|
| 471 |
+
notebookInput.name = "notebook_id";
|
| 472 |
+
notebookInput.value = notebookId;
|
| 473 |
+
form.appendChild(notebookInput);
|
| 474 |
+
|
| 475 |
+
document.body.appendChild(form);
|
| 476 |
+
form.submit();
|
| 477 |
+
} else {
|
| 478 |
+
currentZoneId = parseInt(e.target.value);
|
| 479 |
+
console.log("Zone selected, currentZoneID:", currentZoneId);
|
| 480 |
}
|
| 481 |
+
});
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
//feedback Modal POP-UP on back Button
|
| 485 |
+
backButton.addEventListener("click", async function(event){
|
| 486 |
+
console.log("Back button clicked"); // Debugging line
|
| 487 |
+
event.preventDefault();
|
| 488 |
+
|
| 489 |
+
if(!currentZoneId){
|
| 490 |
+
console.log("no configuration selected, going back directly")
|
| 491 |
+
window.location.href = `/notebook/?effort_id=${effortId}&user_id=${userId}`;
|
| 492 |
+
return;
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
console.log("Debug BackBtn:", {userId, notebookId, currentZoneId, effortId});
|
| 496 |
+
try {
|
| 497 |
+
const response = await fetch(`/chat_feature/user_feedback_eligibility?user_id=${userId}¬ebook_id=${notebookId}&zone_id=${currentZoneId}`);
|
| 498 |
+
const data = await response.json();
|
| 499 |
+
|
| 500 |
+
if (data.eligible_for_feedback) {
|
| 501 |
+
console.log("User is eligible for feedback:", data);// Debugging line
|
| 502 |
+
if(data.has_feedback){
|
| 503 |
+
document.getElementById("feedbackLevel").value = data.rating ||"";
|
| 504 |
+
document.getElementById("comment").value = data.comment ||"";
|
| 505 |
+
document.getElementById("updateNotice").style.display = "block";
|
| 506 |
+
|
| 507 |
+
}
|
| 508 |
+
else{
|
| 509 |
+
document.getElementById("feedbackLevel").value = data.rating ||"";
|
| 510 |
+
document.getElementById("comment").value = data.comment ||"";
|
| 511 |
+
document.getElementById("updateNotice").style.display = "none";
|
| 512 |
+
|
| 513 |
+
}
|
| 514 |
+
bootstrapFeedbackModal.show();
|
| 515 |
+
} else {
|
| 516 |
+
window.location.href = `/notebook/?effort_id=${effortId}&user_id=${userId}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
}
|
| 518 |
+
} catch (error) {
|
| 519 |
+
console.error('Error checking eligibility:', error);
|
| 520 |
+
window.location.href = `/notebook/?effort_id=${effortId}&user_id=${userId}`;
|
| 521 |
+
}
|
| 522 |
+
});
|
| 523 |
+
// Feedback Submit
|
| 524 |
+
document.getElementById("submitFeedback").addEventListener("click", async function () {
|
| 525 |
+
const rating = document.getElementById("feedbackLevel").value;
|
| 526 |
+
const comment = document.getElementById("comment").value;
|
| 527 |
+
|
| 528 |
+
const payload = {
|
| 529 |
+
user_id: userId,
|
| 530 |
+
notebook_id: parseInt(notebookId),
|
| 531 |
+
effort_id: parseInt(effortId),
|
| 532 |
+
zone_id: parseInt(currentZoneId),
|
| 533 |
+
rating: rating ? parseInt(rating) : null,
|
| 534 |
+
comment: comment
|
| 535 |
+
};
|
| 536 |
+
|
| 537 |
+
try {
|
| 538 |
+
const response = await fetch("/chat_feature/submit_feedback", {
|
| 539 |
+
method: "POST",
|
| 540 |
+
headers: { "Content-Type": "application/json" },
|
| 541 |
+
body: JSON.stringify(payload)
|
| 542 |
+
});
|
| 543 |
+
|
| 544 |
+
if (response.ok) {
|
| 545 |
+
bootstrapFeedbackModal.hide();
|
| 546 |
+
window.location.href = `/notebook/?effort_id=${effortId}&user_id=${userId}`;
|
| 547 |
+
} else {
|
| 548 |
+
alert("Error submitting feedback");
|
| 549 |
}
|
| 550 |
+
} catch (error) {
|
| 551 |
+
console.error("Error submitting feedback:", error);
|
| 552 |
+
alert("Error submitting feedback");
|
| 553 |
+
}
|
| 554 |
+
});
|
| 555 |
+
|
| 556 |
+
// Skip feedback
|
| 557 |
+
document.getElementById("skipFeedback").addEventListener("click", function () {
|
| 558 |
+
bootstrapFeedbackModal.hide();
|
| 559 |
+
window.location.href = `/notebook/?effort_id=${effortId}&user_id=${userId}`;
|
| 560 |
+
});
|
| 561 |
+
|
| 562 |
+
function loadFiles() {
|
| 563 |
+
const files = preloadedFiles || [];
|
| 564 |
+
fileList.innerHTML = "";
|
| 565 |
+
|
| 566 |
+
files.forEach(file => {
|
| 567 |
+
const li = document.createElement("li");
|
| 568 |
+
li.className =
|
| 569 |
+
"flex items-center gap-3 p-4 rounded-2xl border border-gray-200 bg-white hover:bg-blue-50 hover:shadow-lg transition shadow group";
|
| 570 |
+
|
| 571 |
+
const fileIcon = document.createElement("div");
|
| 572 |
+
fileIcon.className = "flex-shrink-0 text-blue-600 text-lg";
|
| 573 |
+
fileIcon.textContent = "📄";
|
| 574 |
+
|
| 575 |
+
const fileName = document.createElement("div");
|
| 576 |
+
fileName.className = "flex-1 min-w-0 cursor-pointer";
|
| 577 |
+
fileName.innerHTML = `
|
| 578 |
+
<p class="font-medium truncate group-hover:whitespace-normal group-hover:break-all" title="${file.name}">
|
| 579 |
+
${file.name}
|
| 580 |
+
</p>
|
| 581 |
+
`;
|
| 582 |
+
fileName.onclick = () => {
|
| 583 |
+
currentFileUri = file.uri;
|
| 584 |
+
appendMessage("System", `Selected file: ${file.name}`, "bg-purple-600");
|
| 585 |
+
|
| 586 |
+
document.getElementById("notebook-path").textContent = notebookName;
|
| 587 |
+
document.getElementById("effort-path").textContent = effortName;
|
| 588 |
+
document.getElementById("file-path").textContent = file.name;
|
| 589 |
+
|
| 590 |
+
if (selectedFileElement) {
|
| 591 |
+
selectedFileElement.classList.remove("border-blue-500", "bg-blue-100", "ring", "ring-blue-300", "shadow-lg", "transform", "scale-105");
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
li.classList.add("border-blue-500", "bg-blue-100", "ring", "ring-blue-300", "shadow-lg", "transform", "scale-105");
|
| 595 |
+
selectedFileElement = li;
|
| 596 |
+
};
|
| 597 |
+
|
| 598 |
+
const deleteButton = document.createElement("button");
|
| 599 |
+
deleteButton.className = "btn btn-sm btn-outline-danger";
|
| 600 |
+
deleteButton.setAttribute("data-bs-toggle", "modal");
|
| 601 |
+
deleteButton.setAttribute("data-bs-target", "#deleteFileModal");
|
| 602 |
+
deleteButton.innerHTML = `<i class="bi bi-trash"></i>`;
|
| 603 |
+
deleteButton.onclick = (e) => {
|
| 604 |
+
e.stopPropagation();
|
| 605 |
+
setDeleteFile(file.uri, file.name);
|
| 606 |
+
};
|
| 607 |
+
|
| 608 |
+
li.appendChild(fileIcon);
|
| 609 |
+
li.appendChild(fileName);
|
| 610 |
+
li.appendChild(deleteButton);
|
| 611 |
+
|
| 612 |
+
fileList.appendChild(li);
|
| 613 |
+
});
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
|
| 617 |
+
async function sendMessage() {
|
| 618 |
+
const message = document.getElementById("message").value;
|
| 619 |
+
const persona = document.getElementById("persona").value;
|
| 620 |
+
if (!message.trim() || !currentFileUri) {
|
| 621 |
+
alert("Please select a file and type a message.");
|
| 622 |
+
return;
|
| 623 |
+
}
|
| 624 |
+
if (!currentZoneId) {
|
| 625 |
+
alert("Please select a zone before sending a message.");
|
| 626 |
+
return;
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
appendMessage("You", message, "bg-blue-500", true); // Right aligned
|
| 630 |
+
|
| 631 |
+
const loadingId = "loading-msg";
|
| 632 |
+
const loadingWrapper = document.createElement("div");
|
| 633 |
+
loadingWrapper.id = loadingId;
|
| 634 |
+
loadingWrapper.className = "flex justify-start";
|
| 635 |
+
|
| 636 |
+
const loadingBubble = document.createElement("div");
|
| 637 |
+
loadingBubble.className = "max-w-xl px-4 py-2 rounded-lg bg-gray-300 text-gray-800";
|
| 638 |
+
loadingBubble.innerHTML = `<strong>Assistant:</strong> <span class="loading-dots"><span></span><span></span><span></span></span>`;
|
| 639 |
+
loadingWrapper.appendChild(loadingBubble);
|
| 640 |
+
chatBox.appendChild(loadingWrapper);
|
| 641 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
| 642 |
+
|
| 643 |
+
|
| 644 |
+
const res = await fetch("/chat_feature/send_message", {
|
| 645 |
+
method: "POST",
|
| 646 |
+
headers: { "Content-Type": "application/json" },
|
| 647 |
+
body: JSON.stringify({
|
| 648 |
+
message,
|
| 649 |
+
persona,
|
| 650 |
+
file_uri: currentFileUri,
|
| 651 |
+
experiment_zone_id: currentZoneId,
|
| 652 |
+
effortId: effortId,
|
| 653 |
+
notebookId: notebookId
|
| 654 |
+
})
|
| 655 |
+
});
|
| 656 |
+
|
| 657 |
+
const data = await res.json();
|
| 658 |
+
document.getElementById(loadingId)?.remove();
|
| 659 |
+
appendMessage("Assistant", data.message || "No response", "bg-gray-700");
|
| 660 |
+
document.getElementById("message").value = "";
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
async function summarize() {
|
| 664 |
+
const summaryType = document.getElementById("summary-type").value;
|
| 665 |
+
if (!currentFileUri) {
|
| 666 |
+
alert("Please select a file and summarize.");
|
| 667 |
+
return;
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
if (!currentZoneId) {
|
| 671 |
+
alert("Please select a zone before summarizing.");
|
| 672 |
+
return;
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
appendMessage("You", `Summarize (${summaryType})`, "bg-green-500", true); // Right aligned
|
| 676 |
+
|
| 677 |
+
const loadingId = "loading-msg";
|
| 678 |
+
const loadingWrapper = document.createElement("div");
|
| 679 |
+
loadingWrapper.id = loadingId;
|
| 680 |
+
loadingWrapper.className = "flex justify-start";
|
| 681 |
+
|
| 682 |
+
const loadingBubble = document.createElement("div");
|
| 683 |
+
loadingBubble.className = "max-w-xl px-4 py-2 rounded-lg bg-gray-300 text-gray-800";
|
| 684 |
+
loadingBubble.innerHTML = `<strong>Assistant:</strong> <span class="loading-dots"><span></span><span></span><span></span></span>`;
|
| 685 |
+
loadingWrapper.appendChild(loadingBubble);
|
| 686 |
+
chatBox.appendChild(loadingWrapper);
|
| 687 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
| 688 |
+
|
| 689 |
+
|
| 690 |
+
const res = await fetch("/chat_feature/summarize", {
|
| 691 |
+
method: "POST",
|
| 692 |
+
headers: { "Content-Type": "application/json" },
|
| 693 |
+
body: JSON.stringify({
|
| 694 |
+
summary_type: summaryType,
|
| 695 |
+
file_uri: currentFileUri,
|
| 696 |
+
experiment_zone_id: currentZoneId,
|
| 697 |
+
effortId: effortId,
|
| 698 |
+
notebookId: notebookId
|
| 699 |
+
})
|
| 700 |
+
});
|
| 701 |
+
|
| 702 |
+
const data = await res.json();
|
| 703 |
+
document.getElementById(loadingId)?.remove();
|
| 704 |
+
appendMessage("Summary", data.message || "No summary", "bg-gray-700");
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
function openModal() { modal.classList.remove("hidden"); }
|
| 708 |
+
function closeModal() { modal.classList.add("hidden"); fileInput.value = ""; }
|
| 709 |
+
function triggerFileInput() { fileInput.click(); }
|
| 710 |
+
|
| 711 |
+
async function submitFile() {
|
| 712 |
+
const files = fileInput.files;
|
| 713 |
+
if (!files.length) return alert("Choose at least one file.");
|
| 714 |
+
|
| 715 |
+
const formData = new FormData();
|
| 716 |
+
for (let file of files) {
|
| 717 |
+
if (file.type !== "application/pdf") {
|
| 718 |
+
alert(`Invalid file type: ${file.name}`);
|
| 719 |
+
return;
|
| 720 |
}
|
| 721 |
+
formData.append("files", file);
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
formData.append("effort_id", effortId);
|
| 725 |
+
|
| 726 |
+
try {
|
| 727 |
+
const res = await fetch("/chat_feature/upload_file", {
|
| 728 |
+
method: "POST",
|
| 729 |
+
body: formData
|
| 730 |
+
});
|
| 731 |
+
|
| 732 |
+
const contentType = res.headers.get("content-type") || "";
|
| 733 |
+
let responseData = contentType.includes("application/json") ? await res.json() : await res.text();
|
| 734 |
+
|
| 735 |
+
if (!res.ok) {
|
| 736 |
+
const errorMessage = typeof responseData === "string"
|
| 737 |
+
? responseData
|
| 738 |
+
: (responseData.error || JSON.stringify(responseData));
|
| 739 |
+
alert(`Upload failed: ${errorMessage}`);
|
| 740 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 741 |
}
|
| 742 |
|
| 743 |
+
alert("Upload successful!");
|
| 744 |
+
location.reload(); // Refresh to get updated file list from server
|
| 745 |
+
} catch (err) {
|
| 746 |
+
alert("Error: " + err.message);
|
| 747 |
+
}
|
| 748 |
+
}
|
| 749 |
+
|
| 750 |
+
window.onclick = function (event) {
|
| 751 |
+
if (event.target == modal) closeModal();
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
let deleteFileUriToConfirm = "";
|
| 755 |
+
let deleteFileName = ""
|
| 756 |
+
|
| 757 |
+
function setDeleteFile(fileUri, fileName) {
|
| 758 |
+
deleteFileUriToConfirm = fileUri;
|
| 759 |
+
deleteFileName = fileName
|
| 760 |
+
document.getElementById("deleteFileName").textContent = fileName;
|
| 761 |
+
}
|
| 762 |
+
|
| 763 |
+
async function confirmDeleteFile() {
|
| 764 |
+
try {
|
| 765 |
+
const res = await fetch("/chat_feature/delete_file", {
|
| 766 |
+
method: "POST",
|
| 767 |
+
headers: { "Content-Type": "application/json" },
|
| 768 |
+
body: JSON.stringify({
|
| 769 |
+
file_uri: deleteFileUriToConfirm,
|
| 770 |
+
effort_id: effortId,
|
| 771 |
+
filename: deleteFileName
|
| 772 |
+
})
|
| 773 |
+
});
|
| 774 |
+
|
| 775 |
+
if (!res.ok) {
|
| 776 |
+
const text = await res.text();
|
| 777 |
+
alert("Failed to delete: " + text);
|
| 778 |
+
} else {
|
| 779 |
+
const modal = bootstrap.Modal.getInstance(document.getElementById("deleteFileModal"));
|
| 780 |
+
modal.hide();
|
| 781 |
+
alert("File deleted.");
|
| 782 |
+
location.reload();
|
| 783 |
+
}
|
| 784 |
+
} catch (err) {
|
| 785 |
+
alert("Error deleting file: " + err.message);
|
| 786 |
+
}
|
| 787 |
+
}
|
| 788 |
+
|
| 789 |
+
const dropZone = document.querySelector(".drop-zone");
|
| 790 |
+
|
| 791 |
+
dropZone.addEventListener("dragover", (e) => {
|
| 792 |
+
e.preventDefault();
|
| 793 |
+
dropZone.classList.add("border-blue-500", "text-blue-500");
|
| 794 |
+
});
|
| 795 |
+
|
| 796 |
+
dropZone.addEventListener("dragleave", () => {
|
| 797 |
+
dropZone.classList.remove("border-blue-500", "text-blue-500");
|
| 798 |
+
});
|
| 799 |
+
|
| 800 |
+
dropZone.addEventListener("drop", (e) => {
|
| 801 |
+
e.preventDefault();
|
| 802 |
+
dropZone.classList.remove("border-blue-500", "text-blue-500");
|
| 803 |
+
|
| 804 |
+
const files = e.dataTransfer.files;
|
| 805 |
+
fileInput.files = files;
|
| 806 |
+
|
| 807 |
+
// Optional: Display file names immediately
|
| 808 |
+
const list = document.getElementById("selectedFilesList");
|
| 809 |
+
list.innerHTML = "";
|
| 810 |
+
for (const file of files) {
|
| 811 |
+
const p = document.createElement("p");
|
| 812 |
+
p.textContent = file.name;
|
| 813 |
+
list.appendChild(p);
|
| 814 |
+
}
|
| 815 |
+
});
|
| 816 |
+
|
| 817 |
+
window.onload = function () {
|
| 818 |
+
|
| 819 |
+
loadFiles();
|
| 820 |
+
loadZones();
|
| 821 |
+
|
| 822 |
+
let historyFilename = ""
|
| 823 |
+
|
| 824 |
+
if (chatHistory && chatHistory.length > 0) {
|
| 825 |
+
chatHistory.forEach(entry => {
|
| 826 |
+
|
| 827 |
+
if (entry.filename && (entry.filename !== historyFilename || historyFilename === "")) {
|
| 828 |
+
historyFilename = entry.filename;
|
| 829 |
+
appendMessage("System", `Selected file: ${historyFilename}`, "bg-purple-600");
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
// User message
|
| 833 |
+
const userMessage = entry.question;
|
| 834 |
+
appendMessage("You", userMessage, "bg-blue-500", true);
|
| 835 |
+
const personaMessage = entry.persona;
|
| 836 |
+
appendMessage("Persona", personaMessage, "bg-blue-500", true);
|
| 837 |
+
// Assistant response
|
| 838 |
+
const botMessage = entry.response;
|
| 839 |
+
appendMessage("Assistant", botMessage, "bg-gray-700", false);
|
| 840 |
+
});
|
| 841 |
+
}
|
| 842 |
+
};
|
| 843 |
+
|
| 844 |
+
</script>
|
| 845 |
+
|
| 846 |
+
</body>
|
| 847 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|