Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,424 +1,885 @@
|
|
| 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 |
-
|
| 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 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |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=device-width, initial-scale=1.0">
|
| 6 |
+
<title>FarmaBot - Endocaser | Bilingual Dental Pharmacology Assistant</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
/* Estilos para tablas Markdown */
|
| 11 |
+
.message-content table {
|
| 12 |
+
border-collapse: collapse;
|
| 13 |
+
width: 100%;
|
| 14 |
+
margin: 12px 0;
|
| 15 |
+
font-size: 13px;
|
| 16 |
+
background: #fff;
|
| 17 |
+
border-radius: 8px;
|
| 18 |
+
overflow-x: auto;
|
| 19 |
+
border: 1px solid var(--border);
|
| 20 |
+
display: table;
|
| 21 |
+
}
|
| 22 |
+
.message-content table tbody, .message-content table thead {
|
| 23 |
+
display: table-row-group;
|
| 24 |
+
width: 100%;
|
| 25 |
+
}
|
| 26 |
+
.message-content th, .message-content td {
|
| 27 |
+
padding: 10px 12px;
|
| 28 |
+
text-align: left;
|
| 29 |
+
border: 1px solid var(--border);
|
| 30 |
+
word-break: break-word;
|
| 31 |
+
}
|
| 32 |
+
.message-content th {
|
| 33 |
+
background-color: var(--primary-surface);
|
| 34 |
+
color: var(--primary-dark);
|
| 35 |
+
font-weight: 600;
|
| 36 |
+
white-space: normal;
|
| 37 |
+
}
|
| 38 |
+
.message-content tr:nth-child(even) {
|
| 39 |
+
background-color: #f9fafb;
|
| 40 |
+
}
|
| 41 |
+
/* Modo tarjetas para móvil */
|
| 42 |
+
@media (max-width: 480px) {
|
| 43 |
+
.message-content table {
|
| 44 |
+
display: block;
|
| 45 |
+
border: none;
|
| 46 |
+
margin: 8px 0;
|
| 47 |
+
}
|
| 48 |
+
.message-content table thead {
|
| 49 |
+
display: none;
|
| 50 |
+
}
|
| 51 |
+
.message-content table tbody {
|
| 52 |
+
display: flex;
|
| 53 |
+
flex-direction: column;
|
| 54 |
+
gap: 12px;
|
| 55 |
+
}
|
| 56 |
+
.message-content table tr {
|
| 57 |
+
display: flex;
|
| 58 |
+
flex-direction: column;
|
| 59 |
+
border: 1px solid var(--border);
|
| 60 |
+
border-radius: 8px;
|
| 61 |
+
padding: 12px;
|
| 62 |
+
background: #fff;
|
| 63 |
+
margin-bottom: 0;
|
| 64 |
+
}
|
| 65 |
+
.message-content table tr:nth-child(even) {
|
| 66 |
+
background-color: #fff;
|
| 67 |
+
}
|
| 68 |
+
.message-content table td {
|
| 69 |
+
display: flex;
|
| 70 |
+
justify-content: space-between;
|
| 71 |
+
align-items: flex-start;
|
| 72 |
+
border: none;
|
| 73 |
+
padding: 8px 0;
|
| 74 |
+
border-bottom: 1px solid var(--border);
|
| 75 |
+
}
|
| 76 |
+
.message-content table td:last-child {
|
| 77 |
+
border-bottom: none;
|
| 78 |
+
}
|
| 79 |
+
.message-content table td::before {
|
| 80 |
+
content: attr(data-label);
|
| 81 |
+
font-weight: 600;
|
| 82 |
+
color: var(--primary-dark);
|
| 83 |
+
margin-right: 12px;
|
| 84 |
+
flex-shrink: 0;
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
.message-content ul, .message-content ol {
|
| 88 |
+
padding-left: 20px;
|
| 89 |
+
margin: 8px 0;
|
| 90 |
+
}
|
| 91 |
+
.message-content li {
|
| 92 |
+
margin-bottom: 4px;
|
| 93 |
+
}
|
| 94 |
+
.message-content strong {
|
| 95 |
+
color: var(--primary-dark);
|
| 96 |
+
}
|
| 97 |
+
.message-content p {
|
| 98 |
+
margin: 0 0 8px 0;
|
| 99 |
+
word-wrap: break-word;
|
| 100 |
+
overflow-wrap: break-word;
|
| 101 |
+
}
|
| 102 |
+
:root {
|
| 103 |
+
--primary: #4574E8;
|
| 104 |
+
--primary-light: #6B93F2;
|
| 105 |
+
--primary-dark: #2B4FAD;
|
| 106 |
+
--primary-surface: #EEF2FD;
|
| 107 |
+
--bg: #F7F8FC;
|
| 108 |
+
--surface: #FFFFFF;
|
| 109 |
+
--text-primary: #1A1D26;
|
| 110 |
+
--text-secondary: #6B7280;
|
| 111 |
+
--border: #E5E7EB;
|
| 112 |
+
--hint: #9CA3AF;
|
| 113 |
+
--success: #10B981;
|
| 114 |
+
--error: #EF4444;
|
| 115 |
+
--bot-bg: #F3F4F6;
|
| 116 |
+
--user-bg: #EEF2FD;
|
| 117 |
+
--sidebar-bg: #1A2332;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 121 |
+
|
| 122 |
+
body {
|
| 123 |
+
font-family: 'Inter', sans-serif;
|
| 124 |
+
background: var(--bg);
|
| 125 |
+
color: var(--text-primary);
|
| 126 |
+
height: 100vh;
|
| 127 |
+
overflow: hidden;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.chat-container {
|
| 131 |
+
height: 100vh;
|
| 132 |
+
display: flex;
|
| 133 |
+
flex-direction: column;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/* Header */
|
| 137 |
+
.chat-header {
|
| 138 |
+
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
| 139 |
+
color: #fff;
|
| 140 |
+
padding: 16px 24px;
|
| 141 |
+
display: flex;
|
| 142 |
+
align-items: center;
|
| 143 |
+
gap: 14px;
|
| 144 |
+
flex-shrink: 0;
|
| 145 |
+
box-shadow: 0 4px 20px rgba(69, 116, 232, 0.25);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
.header-logo {
|
| 149 |
+
width: 40px;
|
| 150 |
+
height: 40px;
|
| 151 |
+
background: rgba(255,255,255,0.2);
|
| 152 |
+
border-radius: 12px;
|
| 153 |
+
display: flex;
|
| 154 |
+
align-items: center;
|
| 155 |
+
justify-content: center;
|
| 156 |
+
font-size: 20px;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
.header-info { flex: 1; }
|
| 160 |
+
.header-info h2 {
|
| 161 |
+
font-size: 18px;
|
| 162 |
+
font-weight: 700;
|
| 163 |
+
letter-spacing: -0.3px;
|
| 164 |
+
}
|
| 165 |
+
.header-info span {
|
| 166 |
+
font-size: 12px;
|
| 167 |
+
opacity: 0.75;
|
| 168 |
+
font-weight: 400;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.header-buttons { display: flex; gap: 8px; }
|
| 172 |
+
.icon-btn {
|
| 173 |
+
background: rgba(255,255,255,0.15);
|
| 174 |
+
border: none;
|
| 175 |
+
color: #fff;
|
| 176 |
+
width: 36px;
|
| 177 |
+
height: 36px;
|
| 178 |
+
border-radius: 10px;
|
| 179 |
+
cursor: pointer;
|
| 180 |
+
font-size: 14px;
|
| 181 |
+
transition: all 0.2s;
|
| 182 |
+
display: flex;
|
| 183 |
+
align-items: center;
|
| 184 |
+
justify-content: center;
|
| 185 |
+
}
|
| 186 |
+
.icon-btn:hover { background: rgba(255,255,255,0.25); transform: translateY(-1px); }
|
| 187 |
+
|
| 188 |
+
/* Messages */
|
| 189 |
+
.chat-messages {
|
| 190 |
+
flex: 1;
|
| 191 |
+
padding: 24px;
|
| 192 |
+
overflow-y: auto;
|
| 193 |
+
background: var(--bg);
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.message {
|
| 197 |
+
margin-bottom: 16px;
|
| 198 |
+
display: flex;
|
| 199 |
+
max-width: 85%;
|
| 200 |
+
animation: fadeIn 0.3s ease;
|
| 201 |
+
word-wrap: break-word;
|
| 202 |
+
overflow-wrap: break-word;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
@keyframes fadeIn {
|
| 206 |
+
from { opacity: 0; transform: translateY(8px); }
|
| 207 |
+
to { opacity: 1; transform: translateY(0); }
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
.message.user { margin-left: auto; }
|
| 211 |
+
.message.bot { margin-right: auto; }
|
| 212 |
+
|
| 213 |
+
.bot-avatar {
|
| 214 |
+
width: 32px;
|
| 215 |
+
height: 32px;
|
| 216 |
+
background: var(--primary);
|
| 217 |
+
border-radius: 10px;
|
| 218 |
+
display: flex;
|
| 219 |
+
align-items: center;
|
| 220 |
+
justify-content: center;
|
| 221 |
+
color: #fff;
|
| 222 |
+
font-size: 14px;
|
| 223 |
+
margin-right: 10px;
|
| 224 |
+
flex-shrink: 0;
|
| 225 |
+
margin-top: 2px;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
.message-content {
|
| 229 |
+
padding: 12px 16px;
|
| 230 |
+
border-radius: 16px;
|
| 231 |
+
line-height: 1.6;
|
| 232 |
+
font-size: 14px;
|
| 233 |
+
min-width: 0;
|
| 234 |
+
word-wrap: break-word;
|
| 235 |
+
overflow-wrap: break-word;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
.message.user .message-content {
|
| 239 |
+
background: var(--primary);
|
| 240 |
+
color: #fff;
|
| 241 |
+
border-bottom-right-radius: 4px;
|
| 242 |
+
box-shadow: 0 2px 8px rgba(69, 116, 232, 0.2);
|
| 243 |
+
word-wrap: break-word;
|
| 244 |
+
overflow-wrap: break-word;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
.message.bot .message-content {
|
| 248 |
+
background: var(--surface);
|
| 249 |
+
border: 1px solid var(--border);
|
| 250 |
+
border-bottom-left-radius: 4px;
|
| 251 |
+
box-shadow: 0 1px 4px rgba(0,0,0,0.04);
|
| 252 |
+
word-wrap: break-word;
|
| 253 |
+
overflow-wrap: break-word;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
.message-content p { margin: 0; }
|
| 257 |
+
.message-content p + p { margin-top: 8px; }
|
| 258 |
+
|
| 259 |
+
/* Typing indicator */
|
| 260 |
+
.typing-indicator {
|
| 261 |
+
display: flex;
|
| 262 |
+
align-items: center;
|
| 263 |
+
gap: 4px;
|
| 264 |
+
padding: 4px 0;
|
| 265 |
+
}
|
| 266 |
+
.typing-indicator span {
|
| 267 |
+
width: 7px;
|
| 268 |
+
height: 7px;
|
| 269 |
+
background: var(--primary);
|
| 270 |
+
border-radius: 50%;
|
| 271 |
+
animation: bounce 1.3s linear infinite;
|
| 272 |
+
}
|
| 273 |
+
@keyframes bounce {
|
| 274 |
+
0%, 60%, 100% { transform: translateY(0); }
|
| 275 |
+
30% { transform: translateY(-6px); }
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
/* Welcome message */
|
| 279 |
+
.welcome-card {
|
| 280 |
+
background: var(--surface);
|
| 281 |
+
border: 1px solid var(--border);
|
| 282 |
+
border-radius: 16px;
|
| 283 |
+
padding: 24px;
|
| 284 |
+
text-align: center;
|
| 285 |
+
max-width: 400px;
|
| 286 |
+
margin: 40px auto;
|
| 287 |
+
box-shadow: 0 2px 12px rgba(0,0,0,0.04);
|
| 288 |
+
}
|
| 289 |
+
.welcome-card .icon {
|
| 290 |
+
width: 56px;
|
| 291 |
+
height: 56px;
|
| 292 |
+
background: var(--primary-surface);
|
| 293 |
+
border-radius: 16px;
|
| 294 |
+
display: flex;
|
| 295 |
+
align-items: center;
|
| 296 |
+
justify-content: center;
|
| 297 |
+
margin: 0 auto 16px;
|
| 298 |
+
font-size: 24px;
|
| 299 |
+
color: var(--primary);
|
| 300 |
+
}
|
| 301 |
+
.welcome-card h3 {
|
| 302 |
+
font-size: 18px;
|
| 303 |
+
font-weight: 700;
|
| 304 |
+
margin-bottom: 6px;
|
| 305 |
+
color: var(--text-primary);
|
| 306 |
+
}
|
| 307 |
+
.welcome-card p {
|
| 308 |
+
font-size: 13px;
|
| 309 |
+
color: var(--text-secondary);
|
| 310 |
+
line-height: 1.5;
|
| 311 |
+
}
|
| 312 |
+
.language-selector {
|
| 313 |
+
display: flex;
|
| 314 |
+
gap: 8px;
|
| 315 |
+
justify-content: center;
|
| 316 |
+
margin-top: 16px;
|
| 317 |
+
}
|
| 318 |
+
.lang-btn {
|
| 319 |
+
padding: 8px 16px;
|
| 320 |
+
border: 1px solid var(--primary);
|
| 321 |
+
background: transparent;
|
| 322 |
+
color: var(--primary);
|
| 323 |
+
border-radius: 20px;
|
| 324 |
+
cursor: pointer;
|
| 325 |
+
font-weight: 500;
|
| 326 |
+
font-size: 12px;
|
| 327 |
+
transition: all 0.2s;
|
| 328 |
+
}
|
| 329 |
+
.lang-btn.active {
|
| 330 |
+
background: var(--primary);
|
| 331 |
+
color: #fff;
|
| 332 |
+
}
|
| 333 |
+
.lang-btn:hover {
|
| 334 |
+
background: var(--primary);
|
| 335 |
+
color: #fff;
|
| 336 |
+
}
|
| 337 |
+
.quick-actions {
|
| 338 |
+
display: flex;
|
| 339 |
+
flex-wrap: wrap;
|
| 340 |
+
gap: 8px;
|
| 341 |
+
justify-content: center;
|
| 342 |
+
margin-top: 16px;
|
| 343 |
+
}
|
| 344 |
+
.quick-action {
|
| 345 |
+
background: var(--primary-surface);
|
| 346 |
+
color: var(--primary);
|
| 347 |
+
border: 1px solid rgba(69, 116, 232, 0.15);
|
| 348 |
+
padding: 8px 14px;
|
| 349 |
+
border-radius: 20px;
|
| 350 |
+
font-size: 12px;
|
| 351 |
+
font-weight: 500;
|
| 352 |
+
cursor: pointer;
|
| 353 |
+
transition: all 0.2s;
|
| 354 |
+
}
|
| 355 |
+
.quick-action:hover {
|
| 356 |
+
background: var(--primary);
|
| 357 |
+
color: #fff;
|
| 358 |
+
transform: translateY(-1px);
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
/* Input area */
|
| 362 |
+
.chat-input {
|
| 363 |
+
padding: 16px 24px;
|
| 364 |
+
background: var(--surface);
|
| 365 |
+
border-top: 1px solid var(--border);
|
| 366 |
+
display: flex;
|
| 367 |
+
align-items: flex-end;
|
| 368 |
+
gap: 10px;
|
| 369 |
+
flex-shrink: 0;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
.chat-input textarea {
|
| 373 |
+
flex: 1;
|
| 374 |
+
padding: 12px 16px;
|
| 375 |
+
border: 1px solid var(--border);
|
| 376 |
+
border-radius: 24px;
|
| 377 |
+
resize: none;
|
| 378 |
+
font-size: 14px;
|
| 379 |
+
font-family: 'Inter', sans-serif;
|
| 380 |
+
background: var(--bg);
|
| 381 |
+
color: var(--text-primary);
|
| 382 |
+
transition: border-color 0.2s;
|
| 383 |
+
max-height: 120px;
|
| 384 |
+
min-width: 0;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
/* Media queries para responsividad */
|
| 388 |
+
@media (max-width: 768px) {
|
| 389 |
+
.chat-header {
|
| 390 |
+
padding: 12px 16px;
|
| 391 |
+
}
|
| 392 |
+
.header-info h2 {
|
| 393 |
+
font-size: 16px;
|
| 394 |
+
}
|
| 395 |
+
.header-info span {
|
| 396 |
+
font-size: 11px;
|
| 397 |
+
}
|
| 398 |
+
.chat-messages {
|
| 399 |
+
padding: 16px;
|
| 400 |
+
}
|
| 401 |
+
.message {
|
| 402 |
+
max-width: 90%;
|
| 403 |
+
margin-bottom: 12px;
|
| 404 |
+
}
|
| 405 |
+
.message-content {
|
| 406 |
+
padding: 10px 14px;
|
| 407 |
+
font-size: 13px;
|
| 408 |
+
}
|
| 409 |
+
.message-content th, .message-content td {
|
| 410 |
+
padding: 8px 10px;
|
| 411 |
+
font-size: 12px;
|
| 412 |
+
}
|
| 413 |
+
.chat-input {
|
| 414 |
+
padding: 12px 16px;
|
| 415 |
+
gap: 8px;
|
| 416 |
+
}
|
| 417 |
+
.chat-input textarea {
|
| 418 |
+
padding: 10px 14px;
|
| 419 |
+
font-size: 13px;
|
| 420 |
+
}
|
| 421 |
+
.send-btn {
|
| 422 |
+
width: 40px;
|
| 423 |
+
height: 40px;
|
| 424 |
+
font-size: 14px;
|
| 425 |
+
}
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
@media (max-width: 480px) {
|
| 429 |
+
.chat-header {
|
| 430 |
+
padding: 10px 12px;
|
| 431 |
+
}
|
| 432 |
+
.header-logo {
|
| 433 |
+
width: 32px;
|
| 434 |
+
height: 32px;
|
| 435 |
+
font-size: 16px;
|
| 436 |
+
}
|
| 437 |
+
.header-info h2 {
|
| 438 |
+
font-size: 14px;
|
| 439 |
+
}
|
| 440 |
+
.header-info span {
|
| 441 |
+
font-size: 10px;
|
| 442 |
+
}
|
| 443 |
+
.chat-messages {
|
| 444 |
+
padding: 12px;
|
| 445 |
+
}
|
| 446 |
+
.message {
|
| 447 |
+
max-width: 95%;
|
| 448 |
+
margin-bottom: 10px;
|
| 449 |
+
}
|
| 450 |
+
.bot-avatar {
|
| 451 |
+
width: 28px;
|
| 452 |
+
height: 28px;
|
| 453 |
+
font-size: 12px;
|
| 454 |
+
margin-right: 8px;
|
| 455 |
+
}
|
| 456 |
+
.message-content {
|
| 457 |
+
padding: 8px 12px;
|
| 458 |
+
font-size: 12px;
|
| 459 |
+
border-radius: 12px;
|
| 460 |
+
}
|
| 461 |
+
.message-content ul, .message-content ol {
|
| 462 |
+
padding-left: 16px;
|
| 463 |
+
margin: 6px 0;
|
| 464 |
+
}
|
| 465 |
+
.chat-input {
|
| 466 |
+
padding: 10px 12px;
|
| 467 |
+
gap: 6px;
|
| 468 |
+
}
|
| 469 |
+
.chat-input textarea {
|
| 470 |
+
padding: 8px 12px;
|
| 471 |
+
font-size: 12px;
|
| 472 |
+
border-radius: 20px;
|
| 473 |
+
}
|
| 474 |
+
.send-btn {
|
| 475 |
+
width: 36px;
|
| 476 |
+
height: 36px;
|
| 477 |
+
font-size: 12px;
|
| 478 |
+
border-radius: 10px;
|
| 479 |
+
}
|
| 480 |
+
.welcome-card {
|
| 481 |
+
max-width: 90%;
|
| 482 |
+
padding: 16px;
|
| 483 |
+
margin: 20px auto;
|
| 484 |
+
}
|
| 485 |
+
.welcome-card .icon {
|
| 486 |
+
width: 48px;
|
| 487 |
+
height: 48px;
|
| 488 |
+
font-size: 20px;
|
| 489 |
+
}
|
| 490 |
+
.welcome-card h3 {
|
| 491 |
+
font-size: 16px;
|
| 492 |
+
}
|
| 493 |
+
.welcome-card p {
|
| 494 |
+
font-size: 12px;
|
| 495 |
+
}
|
| 496 |
+
.quick-action {
|
| 497 |
+
padding: 6px 12px;
|
| 498 |
+
font-size: 11px;
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
.chat-input textarea:focus {
|
| 502 |
+
border-color: var(--primary);
|
| 503 |
+
outline: none;
|
| 504 |
+
box-shadow: 0 0 0 3px rgba(69, 116, 232, 0.1);
|
| 505 |
+
}
|
| 506 |
+
.chat-input textarea::placeholder { color: var(--hint); }
|
| 507 |
+
|
| 508 |
+
.send-btn {
|
| 509 |
+
background: var(--primary);
|
| 510 |
+
color: #fff;
|
| 511 |
+
border: none;
|
| 512 |
+
width: 44px;
|
| 513 |
+
height: 44px;
|
| 514 |
+
border-radius: 14px;
|
| 515 |
+
cursor: pointer;
|
| 516 |
+
font-size: 16px;
|
| 517 |
+
transition: all 0.2s;
|
| 518 |
+
display: flex;
|
| 519 |
+
align-items: center;
|
| 520 |
+
justify-content: center;
|
| 521 |
+
box-shadow: 0 2px 8px rgba(69, 116, 232, 0.3);
|
| 522 |
+
}
|
| 523 |
+
.send-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
|
| 524 |
+
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
|
| 525 |
+
|
| 526 |
+
/* Modal */
|
| 527 |
+
.modal-overlay {
|
| 528 |
+
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
|
| 529 |
+
background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
|
| 530 |
+
display: flex; justify-content: center; align-items: center;
|
| 531 |
+
z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.3s;
|
| 532 |
+
}
|
| 533 |
+
.modal-overlay.visible { opacity: 1; visibility: visible; }
|
| 534 |
+
|
| 535 |
+
.modal-content {
|
| 536 |
+
background: var(--surface);
|
| 537 |
+
padding: 28px;
|
| 538 |
+
border-radius: 20px;
|
| 539 |
+
width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto;
|
| 540 |
+
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
|
| 541 |
+
transform: scale(0.95); transition: transform 0.3s;
|
| 542 |
+
}
|
| 543 |
+
.modal-overlay.visible .modal-content { transform: scale(1); }
|
| 544 |
+
|
| 545 |
+
.modal-content h3 {
|
| 546 |
+
margin-bottom: 20px;
|
| 547 |
+
font-size: 18px;
|
| 548 |
+
font-weight: 700;
|
| 549 |
+
color: var(--text-primary);
|
| 550 |
+
display: flex;
|
| 551 |
+
align-items: center;
|
| 552 |
+
gap: 10px;
|
| 553 |
+
}
|
| 554 |
+
.modal-content h3 i { color: var(--primary); }
|
| 555 |
+
|
| 556 |
+
.modal-close {
|
| 557 |
+
position: absolute; top: 16px; right: 16px;
|
| 558 |
+
background: var(--bg); border: none; width: 32px; height: 32px;
|
| 559 |
+
border-radius: 8px; font-size: 16px; color: var(--text-secondary);
|
| 560 |
+
cursor: pointer; display: flex; align-items: center; justify-content: center;
|
| 561 |
+
}
|
| 562 |
+
.modal-close:hover { background: var(--border); }
|
| 563 |
+
|
| 564 |
+
.admin-grid {
|
| 565 |
+
display: grid;
|
| 566 |
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
| 567 |
+
gap: 10px;
|
| 568 |
+
margin-bottom: 20px;
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
.admin-btn {
|
| 572 |
+
background: var(--bg);
|
| 573 |
+
border: 1px solid var(--border);
|
| 574 |
+
color: var(--text-primary);
|
| 575 |
+
padding: 14px;
|
| 576 |
+
border-radius: 12px;
|
| 577 |
+
cursor: pointer;
|
| 578 |
+
font-size: 13px;
|
| 579 |
+
font-weight: 500;
|
| 580 |
+
font-family: 'Inter', sans-serif;
|
| 581 |
+
display: flex;
|
| 582 |
+
align-items: center;
|
| 583 |
+
gap: 10px;
|
| 584 |
+
transition: all 0.2s;
|
| 585 |
+
}
|
| 586 |
+
.admin-btn:hover {
|
| 587 |
+
background: var(--primary);
|
| 588 |
+
color: #fff;
|
| 589 |
+
border-color: var(--primary);
|
| 590 |
+
transform: translateY(-2px);
|
| 591 |
+
box-shadow: 0 4px 12px rgba(69, 116, 232, 0.25);
|
| 592 |
+
}
|
| 593 |
+
.admin-btn i { font-size: 16px; width: 20px; text-align: center; }
|
| 594 |
+
|
| 595 |
+
.status-box {
|
| 596 |
+
background: var(--bg);
|
| 597 |
+
padding: 14px;
|
| 598 |
+
border-radius: 10px;
|
| 599 |
+
font-family: 'JetBrains Mono', monospace;
|
| 600 |
+
font-size: 12px;
|
| 601 |
+
white-space: pre-wrap;
|
| 602 |
+
border: 1px solid var(--border);
|
| 603 |
+
color: var(--text-secondary);
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
.form-group { margin-bottom: 14px; }
|
| 607 |
+
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
|
| 608 |
+
.form-group input {
|
| 609 |
+
width: 100%; padding: 10px 14px;
|
| 610 |
+
border: 1px solid var(--border); border-radius: 10px;
|
| 611 |
+
background: var(--bg); color: var(--text-primary);
|
| 612 |
+
font-family: 'Inter', sans-serif; font-size: 14px;
|
| 613 |
+
}
|
| 614 |
+
.form-group input:focus { border-color: var(--primary); outline: none; }
|
| 615 |
+
|
| 616 |
+
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
|
| 617 |
+
.btn {
|
| 618 |
+
padding: 10px 20px; border-radius: 10px; border: none;
|
| 619 |
+
cursor: pointer; font-weight: 600; font-size: 13px;
|
| 620 |
+
font-family: 'Inter', sans-serif; transition: all 0.2s;
|
| 621 |
+
}
|
| 622 |
+
.btn-primary { background: var(--primary); color: #fff; }
|
| 623 |
+
.btn-primary:hover { background: var(--primary-dark); }
|
| 624 |
+
.btn-secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }
|
| 625 |
+
|
| 626 |
+
/* Scrollbar */
|
| 627 |
+
::-webkit-scrollbar { width: 6px; }
|
| 628 |
+
::-webkit-scrollbar-track { background: transparent; }
|
| 629 |
+
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
|
| 630 |
+
::-webkit-scrollbar-thumb:hover { background: var(--hint); }
|
| 631 |
+
|
| 632 |
+
/* Responsive */
|
| 633 |
+
@media (max-width: 600px) {
|
| 634 |
+
.chat-header { padding: 12px 16px; }
|
| 635 |
+
.chat-messages { padding: 16px; }
|
| 636 |
+
.chat-input { padding: 12px 16px; }
|
| 637 |
+
.message { max-width: 90%; }
|
| 638 |
+
.welcome-card { margin: 20px 16px; }
|
| 639 |
+
}
|
| 640 |
+
</style>
|
| 641 |
+
</head>
|
| 642 |
+
<body>
|
| 643 |
+
|
| 644 |
+
<div class="chat-container">
|
| 645 |
+
<div class="chat-header">
|
| 646 |
+
<div class="header-logo"><i class="fas fa-pills"></i></div>
|
| 647 |
+
<div class="header-info">
|
| 648 |
+
<h2>FarmaBot</h2>
|
| 649 |
+
<span id="header-subtitle">Asistente de farmacología dental - Endocaser</span>
|
| 650 |
+
</div>
|
| 651 |
+
<div class="header-buttons">
|
| 652 |
+
</div>
|
| 653 |
+
</div>
|
| 654 |
+
|
| 655 |
+
<div class="chat-messages" id="chat-messages">
|
| 656 |
+
<div class="welcome-card">
|
| 657 |
+
<div class="icon"><i class="fas fa-capsules"></i></div>
|
| 658 |
+
<h3>FarmaBot</h3>
|
| 659 |
+
<p id="welcome-text">Tu asistente de farmacología dental. Consulta interacciones, dosis, protocolos de medicación y más.</p>
|
| 660 |
+
<div class="language-selector">
|
| 661 |
+
<button class="lang-btn active" id="lang-es" onclick="setLanguage('es')">Español</button>
|
| 662 |
+
<button class="lang-btn" id="lang-en" onclick="setLanguage('en')">English</button>
|
| 663 |
+
</div>
|
| 664 |
+
<div class="quick-actions" id="quick-actions-container">
|
| 665 |
+
<button class="quick-action" onclick="sendQuickAction(this)">Interacciones medicamentosas</button>
|
| 666 |
+
<button class="quick-action" onclick="sendQuickAction(this)">Dosis de amoxicilina</button>
|
| 667 |
+
<button class="quick-action" onclick="sendQuickAction(this)">Analgesia post-endo</button>
|
| 668 |
+
<button class="quick-action" onclick="sendQuickAction(this)">Paciente alérgico a penicilina</button>
|
| 669 |
+
</div>
|
| 670 |
+
</div>
|
| 671 |
+
</div>
|
| 672 |
+
|
| 673 |
+
<div class="chat-input">
|
| 674 |
+
<textarea id="user-input" placeholder="Escribe tu consulta farmacológica... / Write your pharmacological query..." rows="1" disabled></textarea>
|
| 675 |
+
<button id="send-button" class="send-btn" disabled><i class="fas fa-paper-plane"></i></button>
|
| 676 |
+
</div>
|
| 677 |
+
</div>
|
| 678 |
+
|
| 679 |
+
|
| 680 |
+
|
| 681 |
+
<div class="modal-overlay" id="credentials-modal">
|
| 682 |
+
<div class="modal-content" style="max-width: 380px; position: relative;">
|
| 683 |
+
<h3 id="credentials-title"><i class="fas fa-lock"></i> Autenticación</h3>
|
| 684 |
+
<div class="form-group">
|
| 685 |
+
<label for="username-input">Usuario</label>
|
| 686 |
+
<input type="text" id="username-input" autocomplete="username">
|
| 687 |
+
</div>
|
| 688 |
+
<div class="form-group">
|
| 689 |
+
<label for="password-input">Contraseña</label>
|
| 690 |
+
<input type="password" id="password-input" autocomplete="current-password">
|
| 691 |
+
</div>
|
| 692 |
+
<div class="modal-actions">
|
| 693 |
+
<button id="credentials-cancel-btn" class="btn btn-secondary">Cancelar</button>
|
| 694 |
+
<button id="credentials-submit-btn" class="btn btn-primary">Acceder</button>
|
| 695 |
+
</div>
|
| 696 |
+
</div>
|
| 697 |
+
</div>
|
| 698 |
+
|
| 699 |
+
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
| 700 |
+
<script src="https://unpkg.com/autosize@4.0.2/dist/autosize.min.js"></script>
|
| 701 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 702 |
+
<script>
|
| 703 |
+
// Configurar marked para saltos de línea automáticos
|
| 704 |
+
marked.setOptions({
|
| 705 |
+
breaks: true,
|
| 706 |
+
gfm: true
|
| 707 |
+
});
|
| 708 |
+
|
| 709 |
+
// Traducciónes para soporte bilingüe
|
| 710 |
+
const translations = {
|
| 711 |
+
es: {
|
| 712 |
+
welcomeText: 'Tu asistente de farmacología dental. Consulta interacciones, dosis, protocolos de medicación y más.',
|
| 713 |
+
quickActions: [
|
| 714 |
+
'Interacciones medicamentosas',
|
| 715 |
+
'Dosis de amoxicilina',
|
| 716 |
+
'Analgesia post-endo',
|
| 717 |
+
'Paciente alérgico a penicilina'
|
| 718 |
+
],
|
| 719 |
+
headerSubtitle: 'Asistente de farmacología dental - Endocaser',
|
| 720 |
+
placeholder: 'Escribe tu consulta farmacológica...'
|
| 721 |
+
},
|
| 722 |
+
en: {
|
| 723 |
+
welcomeText: 'Your dental pharmacology assistant. Consult drug interactions, dosages, medication protocols and more.',
|
| 724 |
+
quickActions: [
|
| 725 |
+
'Drug interactions',
|
| 726 |
+
'Amoxicillin dosage',
|
| 727 |
+
'Post-endo analgesia',
|
| 728 |
+
'Penicillin-allergic patient'
|
| 729 |
+
],
|
| 730 |
+
headerSubtitle: 'Dental Pharmacology Assistant - Endocaser',
|
| 731 |
+
placeholder: 'Write your pharmacological query...'
|
| 732 |
+
}
|
| 733 |
+
};
|
| 734 |
+
|
| 735 |
+
let currentLanguage = 'es';
|
| 736 |
+
|
| 737 |
+
function setLanguage(lang) {
|
| 738 |
+
currentLanguage = lang;
|
| 739 |
+
const t = translations[lang];
|
| 740 |
+
|
| 741 |
+
// Actualizar UI
|
| 742 |
+
document.getElementById('welcome-text').textContent = t.welcomeText;
|
| 743 |
+
document.getElementById('header-subtitle').textContent = t.headerSubtitle;
|
| 744 |
+
document.getElementById('user-input').placeholder = t.placeholder;
|
| 745 |
+
|
| 746 |
+
// Actualizar botones de acción rápida
|
| 747 |
+
const quickActionButtons = document.querySelectorAll('#quick-actions-container .quick-action');
|
| 748 |
+
quickActionButtons.forEach((btn, index) => {
|
| 749 |
+
if (index < t.quickActions.length) {
|
| 750 |
+
btn.textContent = t.quickActions[index];
|
| 751 |
+
}
|
| 752 |
+
});
|
| 753 |
+
|
| 754 |
+
// Actualizar botones de idioma
|
| 755 |
+
document.getElementById('lang-es').classList.toggle('active', lang === 'es');
|
| 756 |
+
document.getElementById('lang-en').classList.toggle('active', lang === 'en');
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
function sendQuickAction(btn) {
|
| 760 |
+
const input = document.getElementById('user-input');
|
| 761 |
+
input.value = btn.textContent;
|
| 762 |
+
document.getElementById('send-button').click();
|
| 763 |
+
}
|
| 764 |
+
|
| 765 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 766 |
+
let sessionId = null;
|
| 767 |
+
let sessionAuth = { admin: null, report: null };
|
| 768 |
+
|
| 769 |
+
const ui = {
|
| 770 |
+
sendButton: document.getElementById('send-button'),
|
| 771 |
+
userInput: document.getElementById('user-input'),
|
| 772 |
+
chatMessages: document.getElementById('chat-messages'),
|
| 773 |
+
credsModal: {
|
| 774 |
+
overlay: document.getElementById('credentials-modal'),
|
| 775 |
+
title: document.getElementById('credentials-title'),
|
| 776 |
+
usernameInput: document.getElementById('username-input'),
|
| 777 |
+
passwordInput: document.getElementById('password-input'),
|
| 778 |
+
cancelBtn: document.getElementById('credentials-cancel-btn'),
|
| 779 |
+
submitBtn: document.getElementById('credentials-submit-btn')
|
| 780 |
+
}
|
| 781 |
+
};
|
| 782 |
+
|
| 783 |
+
autosize(ui.userInput);
|
| 784 |
+
|
| 785 |
+
const toggleModal = (modal, show) => modal.classList.toggle('visible', show);
|
| 786 |
+
|
| 787 |
+
const initializeChat = async () => {
|
| 788 |
+
try {
|
| 789 |
+
const response = await axios.post('/create-session');
|
| 790 |
+
sessionId = response.data.session_id;
|
| 791 |
+
ui.userInput.disabled = false;
|
| 792 |
+
ui.sendButton.disabled = false;
|
| 793 |
+
} catch (error) {
|
| 794 |
+
console.error('Error creating session:', error);
|
| 795 |
+
appendMessage({sender: 'bot', text: 'Error al iniciar la sesión. Recarga la página.'});
|
| 796 |
+
}
|
| 797 |
+
};
|
| 798 |
+
|
| 799 |
+
const appendMessage = ({ sender, text, isHtml = false }) => {
|
| 800 |
+
// Remove welcome card on first message
|
| 801 |
+
const welcome = ui.chatMessages.querySelector('.welcome-card');
|
| 802 |
+
if (welcome) welcome.remove();
|
| 803 |
+
|
| 804 |
+
const typing = ui.chatMessages.querySelector('.typing-indicator-wrapper');
|
| 805 |
+
if (typing) typing.remove();
|
| 806 |
+
|
| 807 |
+
const el = document.createElement('div');
|
| 808 |
+
el.className = `message ${sender}`;
|
| 809 |
+
|
| 810 |
+
let content = '';
|
| 811 |
+
if (isHtml) {
|
| 812 |
+
content = text;
|
| 813 |
+
} else if (sender === 'bot') {
|
| 814 |
+
// Renderizar Markdown para el bot
|
| 815 |
+
content = marked.parse(text);
|
| 816 |
+
} else {
|
| 817 |
+
// Escapar HTML para el usuario y envolver en párrafo
|
| 818 |
+
content = `<p>${text.replace(/</g, "<").replace(/>/g, ">")}</p>`;
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
if (sender === 'bot') {
|
| 822 |
+
el.innerHTML = `<div class="bot-avatar"><i class="fas fa-pills"></i></div><div class="message-content">${content}</div>`;
|
| 823 |
+
} else {
|
| 824 |
+
el.innerHTML = `<div class="message-content">${content}</div>`;
|
| 825 |
+
}
|
| 826 |
+
|
| 827 |
+
ui.chatMessages.appendChild(el);
|
| 828 |
+
ui.chatMessages.scrollTop = ui.chatMessages.scrollHeight;
|
| 829 |
+
};
|
| 830 |
+
|
| 831 |
+
const showTypingIndicator = () => {
|
| 832 |
+
if (ui.chatMessages.querySelector('.typing-indicator-wrapper')) return;
|
| 833 |
+
const el = document.createElement('div');
|
| 834 |
+
el.className = 'message bot typing-indicator-wrapper';
|
| 835 |
+
el.innerHTML = `<div class="bot-avatar"><i class="fas fa-pills"></i></div><div class="message-content"><div class="typing-indicator"><span></span><span style="animation-delay:0.2s"></span><span style="animation-delay:0.4s"></span></div></div>`;
|
| 836 |
+
ui.chatMessages.appendChild(el);
|
| 837 |
+
ui.chatMessages.scrollTop = ui.chatMessages.scrollHeight;
|
| 838 |
+
};
|
| 839 |
+
|
| 840 |
+
const sendMessage = async () => {
|
| 841 |
+
if (!sessionId) return;
|
| 842 |
+
const message = ui.userInput.value.trim();
|
| 843 |
+
if (!message) return;
|
| 844 |
+
|
| 845 |
+
appendMessage({sender: 'user', text: message});
|
| 846 |
+
ui.userInput.value = '';
|
| 847 |
+
autosize.update(ui.userInput);
|
| 848 |
+
showTypingIndicator();
|
| 849 |
+
|
| 850 |
+
try {
|
| 851 |
+
const response = await axios.post('/chat-bot', { query: message, session_id: sessionId });
|
| 852 |
+
const raw = response.data?.answer || 'Lo siento, no pude procesar la consulta.';
|
| 853 |
+
const clean = raw.replace(/<think>[\s\S]*?<\/think>/, '').trim();
|
| 854 |
+
appendMessage({sender: 'bot', text: clean || 'Respuesta vacía.'});
|
| 855 |
+
} catch (error) {
|
| 856 |
+
appendMessage({sender: 'bot', text: 'Error al procesar. Revisa los logs del servidor.'});
|
| 857 |
+
}
|
| 858 |
+
};
|
| 859 |
+
|
| 860 |
+
const getCredentials = (type) => {
|
| 861 |
+
return new Promise((resolve, reject) => {
|
| 862 |
+
if (sessionAuth[type]) return resolve(sessionAuth[type]);
|
| 863 |
+
ui.credsModal.usernameInput.value = '';
|
| 864 |
+
ui.credsModal.passwordInput.value = '';
|
| 865 |
+
toggleModal(ui.credsModal.overlay, true);
|
| 866 |
+
ui.credsModal.usernameInput.focus();
|
| 867 |
+
const submit = () => { cleanup(); const u = ui.credsModal.usernameInput.value, p = ui.credsModal.passwordInput.value; u && p ? resolve({username:u,password:p}) : reject(new Error('No credentials')); };
|
| 868 |
+
const cancel = () => { cleanup(); reject(new Error('Cancelled')); };
|
| 869 |
+
const cleanup = () => { ui.credsModal.submitBtn.removeEventListener('click', submit); ui.credsModal.cancelBtn.removeEventListener('click', cancel); toggleModal(ui.credsModal.overlay, false); };
|
| 870 |
+
ui.credsModal.submitBtn.addEventListener('click', submit);
|
| 871 |
+
ui.credsModal.cancelBtn.addEventListener('click', cancel);
|
| 872 |
+
});
|
| 873 |
+
};
|
| 874 |
+
|
| 875 |
+
|
| 876 |
+
|
| 877 |
+
// Events
|
| 878 |
+
ui.sendButton.addEventListener('click', sendMessage);
|
| 879 |
+
ui.userInput.addEventListener('keypress', e => e.key==='Enter' && !e.shiftKey && (e.preventDefault(), sendMessage()));
|
| 880 |
+
|
| 881 |
+
initializeChat();
|
| 882 |
+
});
|
| 883 |
+
</script>
|
| 884 |
+
</body>
|
| 885 |
+
</html>
|