Spaces:
Running
Running
Update static/multi-agent.html
Browse files- static/multi-agent.html +614 -510
static/multi-agent.html
CHANGED
|
@@ -1,511 +1,615 @@
|
|
| 1 |
-
|
| 2 |
-
<
|
| 3 |
-
<
|
| 4 |
-
<
|
| 5 |
-
<meta
|
| 6 |
-
<
|
| 7 |
-
<
|
| 8 |
-
<script src="https://cdn.jsdelivr.net/npm/
|
| 9 |
-
<script src="https://
|
| 10 |
-
<
|
| 11 |
-
<link href="https://fonts.googleapis.com/css2?family=
|
| 12 |
-
<link href="https://
|
| 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 |
-
|
| 197 |
-
|
| 198 |
-
}
|
| 199 |
-
.
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 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 |
-
const
|
| 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 |
-
if (
|
| 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 |
-
this.
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
</html>
|
|
|
|
| 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>DigiYatra Assistant</title>
|
| 7 |
+
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js"></script>
|
| 10 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
| 11 |
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 12 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/atom-one-dark.min.css">
|
| 13 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
|
| 14 |
+
<style>
|
| 15 |
+
:root {
|
| 16 |
+
--primary-color: #304b76;;
|
| 17 |
+
--secondary-color: #f0f8ff;
|
| 18 |
+
--text-color: #333;
|
| 19 |
+
--background-color: #f5f7fa;
|
| 20 |
+
}
|
| 21 |
+
body {
|
| 22 |
+
font-family: 'Poppins', sans-serif;
|
| 23 |
+
/* font-family: 'Roboto', sans-serif; */
|
| 24 |
+
line-height: 1.6;
|
| 25 |
+
margin: 0;
|
| 26 |
+
padding: 0;
|
| 27 |
+
background-color: var(--background-color);
|
| 28 |
+
color: var(--text-color);
|
| 29 |
+
}
|
| 30 |
+
#app {
|
| 31 |
+
max-width: 900px;
|
| 32 |
+
margin: 0 auto;
|
| 33 |
+
padding: 10px;
|
| 34 |
+
}
|
| 35 |
+
.chat-container {
|
| 36 |
+
background-color: #ffffff;
|
| 37 |
+
border-radius: 15px;
|
| 38 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
|
| 39 |
+
overflow: hidden;
|
| 40 |
+
display: flex;
|
| 41 |
+
flex-direction: column;
|
| 42 |
+
height: 98vh;
|
| 43 |
+
transition: all 0.3s ease;
|
| 44 |
+
}
|
| 45 |
+
.messages {
|
| 46 |
+
flex-grow: 1;
|
| 47 |
+
overflow-y: auto;
|
| 48 |
+
padding: 20px;
|
| 49 |
+
display: flex;
|
| 50 |
+
flex-direction: column;
|
| 51 |
+
}
|
| 52 |
+
.message {
|
| 53 |
+
max-width: 80%;
|
| 54 |
+
margin-bottom: 20px;
|
| 55 |
+
padding: 10px 20px;
|
| 56 |
+
border-radius: 20px;
|
| 57 |
+
font-size: 16px;
|
| 58 |
+
line-height: 1.5;
|
| 59 |
+
word-wrap: break-word;
|
| 60 |
+
animation: fadeIn 0.5s ease;
|
| 61 |
+
}
|
| 62 |
+
table {
|
| 63 |
+
width: 100%;
|
| 64 |
+
border-collapse: collapse;
|
| 65 |
+
margin-bottom: 20px;
|
| 66 |
+
}
|
| 67 |
+
table, th, td {
|
| 68 |
+
border: 1px solid #ddd;
|
| 69 |
+
}
|
| 70 |
+
th, td {
|
| 71 |
+
padding: 10px;
|
| 72 |
+
text-align: left;
|
| 73 |
+
}
|
| 74 |
+
@keyframes fadeIn {
|
| 75 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 76 |
+
to { opacity: 1; transform: translateY(0); }
|
| 77 |
+
}
|
| 78 |
+
.user-message {
|
| 79 |
+
background-color: var(--primary-color);
|
| 80 |
+
color: #ffffff;
|
| 81 |
+
align-self: flex-end;
|
| 82 |
+
border-bottom-right-radius: 5px;
|
| 83 |
+
}
|
| 84 |
+
.bot-message {
|
| 85 |
+
background-color: var(--secondary-color);
|
| 86 |
+
color: var(--text-color);
|
| 87 |
+
align-self: flex-start;
|
| 88 |
+
border-bottom-left-radius: 5px;
|
| 89 |
+
position: relative; /* Add this line */
|
| 90 |
+
}
|
| 91 |
+
.copy-button {
|
| 92 |
+
position: absolute;
|
| 93 |
+
top: 5px;
|
| 94 |
+
right: 5px;
|
| 95 |
+
background-color: transparent;
|
| 96 |
+
border: none;
|
| 97 |
+
cursor: pointer;
|
| 98 |
+
padding: 5px;
|
| 99 |
+
transition: all 0.3s ease;
|
| 100 |
+
}
|
| 101 |
+
.copy-button svg {
|
| 102 |
+
width: 16px;
|
| 103 |
+
height: 16px;
|
| 104 |
+
stroke: var(--primary-color);
|
| 105 |
+
}
|
| 106 |
+
.copy-button:hover {
|
| 107 |
+
transform: scale(1.1);
|
| 108 |
+
}
|
| 109 |
+
.input-area {
|
| 110 |
+
display: flex;
|
| 111 |
+
padding: 15px;
|
| 112 |
+
background-color: #ffffff;
|
| 113 |
+
border-top: 1px solid #e0e0e0;
|
| 114 |
+
}
|
| 115 |
+
#user-input {
|
| 116 |
+
flex-grow: 1;
|
| 117 |
+
padding: 12px 15px;
|
| 118 |
+
border: 2px solid var(--primary-color);
|
| 119 |
+
border-radius: 15px;
|
| 120 |
+
font-size: 16px;
|
| 121 |
+
outline: none;
|
| 122 |
+
transition: all 0.3s ease;
|
| 123 |
+
}
|
| 124 |
+
#user-input:focus {
|
| 125 |
+
box-shadow: 0 0 0 3px rgba(0,119,190,0.3);
|
| 126 |
+
}
|
| 127 |
+
.send-button, .reset-button {
|
| 128 |
+
background-color: var(--primary-color);
|
| 129 |
+
color: #ffffff;
|
| 130 |
+
border: none;
|
| 131 |
+
border-radius: 50%;
|
| 132 |
+
width: 50px;
|
| 133 |
+
height: 50px;
|
| 134 |
+
margin-left: 10px;
|
| 135 |
+
cursor: pointer;
|
| 136 |
+
display: flex;
|
| 137 |
+
align-items: center;
|
| 138 |
+
justify-content: center;
|
| 139 |
+
transition: all 0.3s ease;
|
| 140 |
+
}
|
| 141 |
+
.send-button:hover, .reset-button:hover {
|
| 142 |
+
background-color: #005fa3;
|
| 143 |
+
transform: scale(1.05);
|
| 144 |
+
}
|
| 145 |
+
.send-button svg, .reset-button svg {
|
| 146 |
+
width: 24px;
|
| 147 |
+
height: 24px;
|
| 148 |
+
}
|
| 149 |
+
.option-buttons {
|
| 150 |
+
display: flex;
|
| 151 |
+
flex-wrap: wrap;
|
| 152 |
+
gap: 10px;
|
| 153 |
+
margin-top: 15px;
|
| 154 |
+
}
|
| 155 |
+
.option-button {
|
| 156 |
+
background-color: #ffffff;
|
| 157 |
+
border: 2px solid var(--primary-color);
|
| 158 |
+
border-radius: 20px;
|
| 159 |
+
padding: 8px 16px;
|
| 160 |
+
font-size: 14px;
|
| 161 |
+
cursor: pointer;
|
| 162 |
+
transition: all 0.3s ease;
|
| 163 |
+
}
|
| 164 |
+
.option-button:hover {
|
| 165 |
+
background-color: var(--secondary-color);
|
| 166 |
+
transform: translateY(-2px);
|
| 167 |
+
}
|
| 168 |
+
.option-button.selected {
|
| 169 |
+
background-color: var(--primary-color);
|
| 170 |
+
color: #ffffff;
|
| 171 |
+
}
|
| 172 |
+
.audio-button {
|
| 173 |
+
background: none;
|
| 174 |
+
border: none;
|
| 175 |
+
cursor: pointer;
|
| 176 |
+
padding: 0;
|
| 177 |
+
margin-top: 10px;
|
| 178 |
+
transition: all 0.3s ease;
|
| 179 |
+
}
|
| 180 |
+
.audio-button:hover {
|
| 181 |
+
transform: scale(1.1);
|
| 182 |
+
}
|
| 183 |
+
.audio-button svg {
|
| 184 |
+
width: 30px;
|
| 185 |
+
height: 30px;
|
| 186 |
+
fill: var(--primary-color);
|
| 187 |
+
}
|
| 188 |
+
@media (max-width: 600px) {
|
| 189 |
+
#app {
|
| 190 |
+
padding: 10px;
|
| 191 |
+
}
|
| 192 |
+
.chat-container {
|
| 193 |
+
height: 95vh;
|
| 194 |
+
}
|
| 195 |
+
.message {
|
| 196 |
+
max-width: 90%;
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
.dot {
|
| 200 |
+
display: inline-block;
|
| 201 |
+
width: 8px;
|
| 202 |
+
height: 8px;
|
| 203 |
+
border-radius: 50%;
|
| 204 |
+
background-color: #5853c0;
|
| 205 |
+
margin: 0 3px;
|
| 206 |
+
animation: bounce 1.4s infinite ease-in-out;
|
| 207 |
+
}
|
| 208 |
+
.dot:nth-child(1) { animation-delay: -0.32s; }
|
| 209 |
+
.dot:nth-child(2) { animation-delay: -0.16s; }
|
| 210 |
+
@keyframes bounce {
|
| 211 |
+
0%, 80%, 100% {
|
| 212 |
+
transform: scale(0);
|
| 213 |
+
} 40% {
|
| 214 |
+
transform: scale(1.0);
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
.chat-container {
|
| 218 |
+
position: relative;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.input-area {
|
| 222 |
+
position: absolute;
|
| 223 |
+
bottom: 0;
|
| 224 |
+
left: 0;
|
| 225 |
+
right: 0;
|
| 226 |
+
z-index: 10;
|
| 227 |
+
transition: transform 0.3s ease;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
.messages {
|
| 231 |
+
padding-bottom: 80px;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.input-hidden {
|
| 235 |
+
transform: translateY(100%);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
.tool-options {
|
| 239 |
+
position: absolute;
|
| 240 |
+
bottom: 100%;
|
| 241 |
+
left: 0;
|
| 242 |
+
background-color: #ffffff;
|
| 243 |
+
border: 1px solid #ddd;
|
| 244 |
+
border-radius: 8px;
|
| 245 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
|
| 246 |
+
display: flex;
|
| 247 |
+
flex-direction: column;
|
| 248 |
+
width: auto;
|
| 249 |
+
min-width: 120px;
|
| 250 |
+
margin-bottom: 10px; /* Added padding for better spacing */
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
.tool-options button {
|
| 254 |
+
padding: 10px 15px;
|
| 255 |
+
border: none;
|
| 256 |
+
background: none;
|
| 257 |
+
text-align: left;
|
| 258 |
+
cursor: pointer;
|
| 259 |
+
white-space: nowrap;
|
| 260 |
+
transition: background-color 0.3s ease;
|
| 261 |
+
font-size: 16px;
|
| 262 |
+
font-weight: 500;
|
| 263 |
+
color: #333; /* Added margin to separate buttons */
|
| 264 |
+
border-radius: 4px; /* Added border radius for a floating effect */
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.tool-options button:hover {
|
| 268 |
+
background-color: #e0e0e0;
|
| 269 |
+
color: #000;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
</style>
|
| 273 |
+
</head>
|
| 274 |
+
<body>
|
| 275 |
+
<div id="app">
|
| 276 |
+
<div class="chat-container">
|
| 277 |
+
<div class="messages" ref="messageContainer" @scroll="handleScroll">
|
| 278 |
+
<div v-for="(message, index) in messages" :key="index"
|
| 279 |
+
:class="['message', message.type === 'user' ? 'user-message' : 'bot-message']">
|
| 280 |
+
<div v-if="message.type === 'bot' && message.content === ''" id="typing-animation"></div>
|
| 281 |
+
<div v-else v-html="message.content"></div>
|
| 282 |
+
<button v-if="message.type === 'bot' && message.audio" @click="toggleAudio(index)" class="audio-button">
|
| 283 |
+
<svg v-if="!message.isPlaying" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
| 284 |
+
<path d="M8 5v14l11-7z"/>
|
| 285 |
+
</svg>
|
| 286 |
+
<svg v-else xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
| 287 |
+
<path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/>
|
| 288 |
+
</svg>
|
| 289 |
+
</button>
|
| 290 |
+
<button v-if="message.type === 'bot' && message.rawResponse" @click="copyMarkdownToClipboard(message.rawResponse)" class="copy-button">
|
| 291 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 292 |
+
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path>
|
| 293 |
+
<rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect>
|
| 294 |
+
</svg>
|
| 295 |
+
</button>
|
| 296 |
+
</div>
|
| 297 |
+
</div>
|
| 298 |
+
<div class="input-area" :class="{ 'input-hidden': isScrollingUp }">
|
| 299 |
+
<div v-if="showToolOptions" class="tool-options">
|
| 300 |
+
<button @click="selectTool('web')">/web</button>
|
| 301 |
+
<button @click="selectTool('news')">/news</button>
|
| 302 |
+
</div>
|
| 303 |
+
<input type="text" id="user-input" v-model="userInput" @keyup.enter="sendMessage" @input="handleInput($event)" placeholder="Type your message... (type / to see available tools)">
|
| 304 |
+
|
| 305 |
+
<button class="send-button" @click="sendMessage">
|
| 306 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 307 |
+
<line x1="22" y1="2" x2="11" y2="13"></line>
|
| 308 |
+
<polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
|
| 309 |
+
</svg>
|
| 310 |
+
</button>
|
| 311 |
+
<button class="reset-button" @click="resetConversation">
|
| 312 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 313 |
+
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path>
|
| 314 |
+
<path d="M3 3v5h5"></path>
|
| 315 |
+
</svg>
|
| 316 |
+
</button>
|
| 317 |
+
</div>
|
| 318 |
+
</div>
|
| 319 |
+
</div>
|
| 320 |
+
|
| 321 |
+
<script>
|
| 322 |
+
marked.setOptions({
|
| 323 |
+
highlight: function (code, lang) {
|
| 324 |
+
if (lang && hljs.getLanguage(lang)) {
|
| 325 |
+
return hljs.highlight(code, { language: lang }).value;
|
| 326 |
+
} else {
|
| 327 |
+
return hljs.highlightAuto(code).value;
|
| 328 |
+
}
|
| 329 |
+
},
|
| 330 |
+
sanitize: false
|
| 331 |
+
});
|
| 332 |
+
|
| 333 |
+
function createTypingAnimation() {
|
| 334 |
+
const container = document.getElementById('typing-animation');
|
| 335 |
+
for (let i = 0; i < 3; i++) {
|
| 336 |
+
const dot = document.createElement('div');
|
| 337 |
+
dot.className = 'dot';
|
| 338 |
+
container.appendChild(dot);
|
| 339 |
+
}
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
const app = new Vue({
|
| 343 |
+
el: '#app',
|
| 344 |
+
data: {
|
| 345 |
+
messages: [],
|
| 346 |
+
userInput: '',
|
| 347 |
+
selectedOptions: {},
|
| 348 |
+
conversationId: '',
|
| 349 |
+
currentAudio: null,
|
| 350 |
+
isScrollingUp: false,
|
| 351 |
+
lastScrollTop: 0,
|
| 352 |
+
tool_call: 'auto',
|
| 353 |
+
showToolOptions: false,
|
| 354 |
+
},
|
| 355 |
+
methods: {
|
| 356 |
+
async sendMessage() {
|
| 357 |
+
if (!this.userInput.trim()) return;
|
| 358 |
+
|
| 359 |
+
this.messages.push({ type: 'user', content: marked.parse(this.userInput) });
|
| 360 |
+
const message = this.userInput;
|
| 361 |
+
this.userInput = '';
|
| 362 |
+
this.selectedOptions = {};
|
| 363 |
+
let streamingIndex = this.messages.push({ type: 'bot', content: '' }) - 1;
|
| 364 |
+
|
| 365 |
+
this.$nextTick(() => {
|
| 366 |
+
createTypingAnimation();
|
| 367 |
+
});
|
| 368 |
+
|
| 369 |
+
try {
|
| 370 |
+
const response = await fetch('https://pvanand-general-chat.hf.space/v2/followup-tools-agent', {
|
| 371 |
+
method: 'POST',
|
| 372 |
+
headers: {
|
| 373 |
+
'Content-Type': 'application/json',
|
| 374 |
+
'X-API-Key': '44d5c2ac18ced6fc25c1e57dcd06fc0b31fb4ad97bf56e67540671a647465df4'
|
| 375 |
+
},
|
| 376 |
+
body: JSON.stringify({
|
| 377 |
+
query: message,
|
| 378 |
+
model_id: 'openai/gpt-4o-mini',
|
| 379 |
+
conversation_id: this.conversationId,
|
| 380 |
+
user_id: 'string',
|
| 381 |
+
tool_call: this.tool_call,
|
| 382 |
+
})
|
| 383 |
+
});
|
| 384 |
+
const reader = response.body.getReader();
|
| 385 |
+
let rawResponse = '';
|
| 386 |
+
let jsonData = null;
|
| 387 |
+
while (true) {
|
| 388 |
+
const { done, value } = await reader.read();
|
| 389 |
+
if (done) break;
|
| 390 |
+
const chunk = new TextDecoder().decode(value);
|
| 391 |
+
if (chunk.includes('<json>')) {
|
| 392 |
+
const [textPart, jsonPart] = chunk.split('<json>');
|
| 393 |
+
rawResponse += textPart;
|
| 394 |
+
const jsonString = jsonPart.split('</json>')[0];
|
| 395 |
+
try {
|
| 396 |
+
jsonData = JSON.parse(jsonString);
|
| 397 |
+
} catch (error) {
|
| 398 |
+
console.error("JSON parsing error:", error);
|
| 399 |
+
console.log("Raw JSON string:", jsonString);
|
| 400 |
+
}
|
| 401 |
+
} else {
|
| 402 |
+
rawResponse += chunk;
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
rawResponse = rawResponse.replace(/<\/?response>/g, '');
|
| 406 |
+
rawResponse = rawResponse.replace(/<tools>[\s\S]*?<\/tools>/g, '');
|
| 407 |
+
rawResponse = rawResponse.replace(/<interact>[\s\S]*?<\/interact>/g, '');
|
| 408 |
+
rawResponse = rawResponse.replace(/<tool>[\s\S]*?<\/tool>/g, '');
|
| 409 |
+
this.$set(this.messages[streamingIndex], 'content', marked.parse(rawResponse));
|
| 410 |
+
this.$set(this.messages[streamingIndex], 'rawResponse', rawResponse);
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
if (jsonData) {
|
| 414 |
+
if (jsonData.tools && jsonData.tools.length > 0) {
|
| 415 |
+
let toolsMessage = "\n\n**Tools Used:**\n";
|
| 416 |
+
jsonData.tools.forEach(tool => {
|
| 417 |
+
toolsMessage += `- ${tool.name.charAt(0).toUpperCase() + tool.name.slice(1)}: ${tool.input}\n`;
|
| 418 |
+
});
|
| 419 |
+
|
| 420 |
+
this.$set(this.messages[streamingIndex], 'content', this.messages[streamingIndex].content + marked.parse(toolsMessage));
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
if (jsonData.clarification && jsonData.clarification.length > 0) {
|
| 424 |
+
streamingIndex = this.messages.push({ type: 'bot', content: '' }) - 1;
|
| 425 |
+
this.renderClarificationQuestions(jsonData.clarification, streamingIndex);
|
| 426 |
+
}
|
| 427 |
+
}
|
| 428 |
+
const audioUrl = await this.convertToSpeech(rawResponse);
|
| 429 |
+
if (audioUrl) {
|
| 430 |
+
this.$set(this.messages[streamingIndex], 'audio', audioUrl);
|
| 431 |
+
}
|
| 432 |
+
} catch (error) {
|
| 433 |
+
console.error('Error:', error);
|
| 434 |
+
this.messages.push({ type: 'bot', content: 'An error occurred while processing your request.' });
|
| 435 |
+
}
|
| 436 |
+
this.$nextTick(() => this.scrollToBottom());
|
| 437 |
+
},
|
| 438 |
+
handleScroll(event) {
|
| 439 |
+
const st = event.target.scrollTop;
|
| 440 |
+
this.isScrollingUp = st < this.lastScrollTop;
|
| 441 |
+
this.lastScrollTop = st <= 0 ? 0 : st;
|
| 442 |
+
},
|
| 443 |
+
renderClarificationQuestions(clarification, messageIndex) {
|
| 444 |
+
if (!clarification || clarification.length === 0) return;
|
| 445 |
+
|
| 446 |
+
let clarificationHtml = '';
|
| 447 |
+
clarification.forEach((item, questionIndex) => {
|
| 448 |
+
clarificationHtml += `<strong>${item.question}</strong><br>`;
|
| 449 |
+
clarificationHtml += '<div class="option-buttons">';
|
| 450 |
+
item.options.forEach((option, optionIndex) => {
|
| 451 |
+
const escapedOption = option.replace(/'/g, "\\'");
|
| 452 |
+
clarificationHtml += `<button class="option-button" onclick="app.toggleOption('${escapedOption}', ${questionIndex}, ${optionIndex})">${option}</button>`;
|
| 453 |
+
});
|
| 454 |
+
clarificationHtml += '</div><br>';
|
| 455 |
+
});
|
| 456 |
+
|
| 457 |
+
this.$set(this.messages[messageIndex], 'content', this.messages[messageIndex].content + marked.parse(clarificationHtml));
|
| 458 |
+
this.$nextTick(() => {
|
| 459 |
+
this.scrollToBottom();
|
| 460 |
+
this.updateButtonStates();
|
| 461 |
+
});
|
| 462 |
+
},
|
| 463 |
+
toggleOption(option, questionIndex, optionIndex) {
|
| 464 |
+
if (!this.selectedOptions[questionIndex]) {
|
| 465 |
+
this.$set(this.selectedOptions, questionIndex, []);
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
const index = this.selectedOptions[questionIndex].indexOf(option);
|
| 469 |
+
if (index > -1) {
|
| 470 |
+
this.selectedOptions[questionIndex].splice(index, 1);
|
| 471 |
+
} else {
|
| 472 |
+
this.selectedOptions[questionIndex].push(option);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
this.updateInputFromSelectedOptions();
|
| 476 |
+
this.updateButtonStates();
|
| 477 |
+
},
|
| 478 |
+
updateInputFromSelectedOptions() {
|
| 479 |
+
this.userInput = Object.entries(this.selectedOptions)
|
| 480 |
+
.map(([questionIndex, options]) =>
|
| 481 |
+
`Q${parseInt(questionIndex) + 1}: ${options.join(', ')}`)
|
| 482 |
+
.join(' | ');
|
| 483 |
+
this.$nextTick(() => document.getElementById('user-input').focus());
|
| 484 |
+
},
|
| 485 |
+
updateButtonStates() {
|
| 486 |
+
Object.entries(this.selectedOptions).forEach(([questionIndex, options]) => {
|
| 487 |
+
const buttons = document.querySelectorAll(`.option-buttons:nth-of-type(${parseInt(questionIndex) + 1}) .option-button`);
|
| 488 |
+
buttons.forEach((button) => {
|
| 489 |
+
if (options.includes(button.textContent)) {
|
| 490 |
+
button.classList.add('selected');
|
| 491 |
+
} else {
|
| 492 |
+
button.classList.remove('selected');
|
| 493 |
+
}
|
| 494 |
+
});
|
| 495 |
+
});
|
| 496 |
+
},
|
| 497 |
+
resetConversation() {
|
| 498 |
+
this.conversationId = uuid.v4();
|
| 499 |
+
this.messages = [];
|
| 500 |
+
this.selectedOptions = {};
|
| 501 |
+
this.userInput = '';
|
| 502 |
+
this.isScrollingUp = false;
|
| 503 |
+
this.lastScrollTop = 0;
|
| 504 |
+
this.tool_call = 'auto';
|
| 505 |
+
this.showToolOptions = false;
|
| 506 |
+
|
| 507 |
+
this.$nextTick(() => {
|
| 508 |
+
if (this.$refs.messageContainer) {
|
| 509 |
+
this.$refs.messageContainer.scrollTop = 0;
|
| 510 |
+
}
|
| 511 |
+
});
|
| 512 |
+
|
| 513 |
+
const inputArea = document.querySelector('.input-area');
|
| 514 |
+
if (inputArea) inputArea.classList.remove('input-hidden');
|
| 515 |
+
},
|
| 516 |
+
scrollToBottom() {
|
| 517 |
+
const container = this.$refs.messageContainer;
|
| 518 |
+
container.scrollTop = container.scrollHeight;
|
| 519 |
+
},
|
| 520 |
+
async convertToSpeech(text) {
|
| 521 |
+
const voice = 'en-US-JennyNeural';
|
| 522 |
+
const encodedText = encodeURIComponent(text);
|
| 523 |
+
try {
|
| 524 |
+
const response = await fetch(`https://pvanand-audio-chat.hf.space/tts?text=${encodedText}&voice=${voice}`, {
|
| 525 |
+
method: 'GET',
|
| 526 |
+
headers: {
|
| 527 |
+
'accept': 'application/json'
|
| 528 |
+
}
|
| 529 |
+
});
|
| 530 |
+
if (!response.ok) {
|
| 531 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
| 532 |
+
}
|
| 533 |
+
const blob = await response.blob();
|
| 534 |
+
return URL.createObjectURL(blob);
|
| 535 |
+
} catch (error) {
|
| 536 |
+
console.error('Error:', error);
|
| 537 |
+
return null;
|
| 538 |
+
}
|
| 539 |
+
},
|
| 540 |
+
toggleAudio(index) {
|
| 541 |
+
const message = this.messages[index];
|
| 542 |
+
if (this.currentAudio && this.currentAudio !== message.audioElement) {
|
| 543 |
+
this.currentAudio.pause();
|
| 544 |
+
this.messages.forEach(m => {
|
| 545 |
+
if (m.audioElement === this.currentAudio) {
|
| 546 |
+
m.isPlaying = false;
|
| 547 |
+
}
|
| 548 |
+
});
|
| 549 |
+
}
|
| 550 |
+
if (!message.audioElement) {
|
| 551 |
+
message.audioElement = new Audio(message.audio);
|
| 552 |
+
message.audioElement.addEventListener('ended', () => {
|
| 553 |
+
message.isPlaying = false;
|
| 554 |
+
this.$forceUpdate();
|
| 555 |
+
});
|
| 556 |
+
}
|
| 557 |
+
if (message.isPlaying) {
|
| 558 |
+
message.audioElement.pause();
|
| 559 |
+
} else {
|
| 560 |
+
message.audioElement.play();
|
| 561 |
+
this.currentAudio = message.audioElement;
|
| 562 |
+
}
|
| 563 |
+
message.isPlaying = !message.isPlaying;
|
| 564 |
+
this.$forceUpdate();
|
| 565 |
+
},
|
| 566 |
+
// remove alert
|
| 567 |
+
copyMarkdownToClipboard(rawResponse) {
|
| 568 |
+
navigator.clipboard.writeText(rawResponse).then(() => {
|
| 569 |
+
// remove alert
|
| 570 |
+
}).catch(err => {
|
| 571 |
+
console.error('Failed to copy: ', err);
|
| 572 |
+
});
|
| 573 |
+
},
|
| 574 |
+
handleInput(event) {
|
| 575 |
+
console.log("Input event triggered", event.target.value); // For debugging
|
| 576 |
+
if (event.target.value === '/') {
|
| 577 |
+
console.log("Slash detected, showing tool options"); // For debugging
|
| 578 |
+
this.showToolOptions = true;
|
| 579 |
+
} else {
|
| 580 |
+
this.showToolOptions = false;
|
| 581 |
+
}
|
| 582 |
+
},
|
| 583 |
+
selectTool(tool) {
|
| 584 |
+
if (tool === 'web') {
|
| 585 |
+
this.tool_call = 'web';
|
| 586 |
+
this.userInput = '/web ';
|
| 587 |
+
} else if (tool === 'news') {
|
| 588 |
+
this.tool_call = 'news';
|
| 589 |
+
this.userInput = '/news ';
|
| 590 |
+
}
|
| 591 |
+
this.showToolOptions = false;
|
| 592 |
+
this.$nextTick(() => {
|
| 593 |
+
const inputElement = document.getElementById('user-input');
|
| 594 |
+
inputElement.focus();
|
| 595 |
+
inputElement.setSelectionRange(inputElement.value.length, inputElement.value.length);
|
| 596 |
+
});
|
| 597 |
+
},
|
| 598 |
+
watch: {
|
| 599 |
+
userInput(newVal, oldVal) {
|
| 600 |
+
console.log("userInput changed", newVal); // For debugging
|
| 601 |
+
if (newVal === '/') {
|
| 602 |
+
this.showToolOptions = true;
|
| 603 |
+
} else {
|
| 604 |
+
this.showToolOptions = false;
|
| 605 |
+
}
|
| 606 |
+
}
|
| 607 |
+
},
|
| 608 |
+
},
|
| 609 |
+
mounted() {
|
| 610 |
+
this.resetConversation();
|
| 611 |
+
}
|
| 612 |
+
});
|
| 613 |
+
</script>
|
| 614 |
+
</body>
|
| 615 |
</html>
|