Update modules/interface.py
Browse files- modules/interface.py +693 -786
modules/interface.py
CHANGED
|
@@ -3,6 +3,7 @@ import re
|
|
| 3 |
import os
|
| 4 |
import time
|
| 5 |
import json
|
|
|
|
| 6 |
from modules.listen import transcribe_audio_file
|
| 7 |
from modules.talker.talk import speak
|
| 8 |
|
|
@@ -13,18 +14,13 @@ try:
|
|
| 13 |
browser_chat,
|
| 14 |
scientist_chat,
|
| 15 |
regular_chat,
|
| 16 |
-
document_chat
|
| 17 |
)
|
| 18 |
except ImportError:
|
| 19 |
-
print("Error: No se pudieron importar los módulos de chat.")
|
| 20 |
|
| 21 |
# ════════════════════════════════════════════════════════════
|
| 22 |
-
#
|
| 23 |
-
# ════════════════════════════════════════════════════════════
|
| 24 |
-
PLACEHOLDER = "Escribe tu mensaje para CVision..."
|
| 25 |
-
|
| 26 |
-
# ════════════════════════════════════════════════════════════
|
| 27 |
-
# CSS FUTURISTA — Diamante × Cyan
|
| 28 |
# ════════════════════════════════════════════════════════════
|
| 29 |
CUSTOM_CSS = """
|
| 30 |
/* ── Google Fonts ── */
|
|
@@ -32,35 +28,36 @@ CUSTOM_CSS = """
|
|
| 32 |
|
| 33 |
/* ── Variables globales ── */
|
| 34 |
:root {
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
}
|
| 56 |
|
| 57 |
/* ── Reset base ── */
|
| 58 |
*, *::before, *::after { box-sizing: border-box; }
|
| 59 |
body, .gradio-container {
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
}
|
| 65 |
|
| 66 |
/* scrollbar */
|
|
@@ -70,72 +67,78 @@ body, .gradio-container {
|
|
| 70 |
|
| 71 |
/* ── Grid de fondo ── */
|
| 72 |
.gradio-container::before {
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
}
|
| 81 |
|
| 82 |
/* ── Scanline animado ── */
|
| 83 |
.gradio-container::after {
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
}
|
| 90 |
@keyframes scanDown {
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
}
|
| 96 |
|
| 97 |
/* ══════════════════════════════════════════
|
| 98 |
-
|
| 99 |
══════════════════════════════════��═══════ */
|
| 100 |
#cvision-header {
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
| 109 |
}
|
| 110 |
|
| 111 |
-
/*
|
|
|
|
|
|
|
| 112 |
#nebula-outer {
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
| 119 |
}
|
|
|
|
| 120 |
#nebula-ring-wrap {
|
| 121 |
-
|
| 122 |
-
|
|
|
|
| 123 |
}
|
| 124 |
#nebula-canvas-wrap {
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
}
|
| 133 |
#nebulaCanvas { width: 100%; height: 100%; display: block; }
|
| 134 |
|
| 135 |
/* anillos externos decorativos */
|
| 136 |
.nebula-deco-ring {
|
| 137 |
-
|
| 138 |
-
|
| 139 |
}
|
| 140 |
.nebula-deco-ring.r1 { inset: -20px; animation: spin 18s linear infinite; }
|
| 141 |
.nebula-deco-ring.r2 { inset: -38px; border-style: dashed; animation: spin 30s linear infinite reverse; }
|
|
@@ -143,281 +146,281 @@ body, .gradio-container {
|
|
| 143 |
|
| 144 |
/* hero info al lado de la nebula */
|
| 145 |
#nebula-info {
|
| 146 |
-
|
| 147 |
-
|
| 148 |
}
|
| 149 |
.hero-eyebrow {
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
}
|
| 154 |
.hero-title {
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
}
|
| 160 |
.hero-title .accent {
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
}
|
| 165 |
.hero-desc {
|
| 166 |
-
|
| 167 |
-
|
| 168 |
}
|
| 169 |
.hero-chips { display: flex; flex-wrap: wrap; gap: 7px; }
|
| 170 |
.hero-chip {
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
}
|
| 176 |
|
| 177 |
/* ══════════════════════════════════════════
|
| 178 |
-
|
| 179 |
══════════════════════════════════════════ */
|
| 180 |
.tab-nav {
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
}
|
| 187 |
.tab-nav button {
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
}
|
| 200 |
.tab-nav button:hover { color: var(--diamond2) !important; }
|
| 201 |
.tab-nav button.selected {
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
}
|
| 206 |
|
| 207 |
/* ══════════════════════════════════════════
|
| 208 |
-
|
| 209 |
══════════════════════════════════════════ */
|
| 210 |
.chatbot-wrap .wrap {
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
}
|
| 217 |
/* burbujas bot */
|
| 218 |
.chatbot-wrap .message.bot,
|
| 219 |
.chatbot-wrap [data-testid="bot"] {
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
}
|
| 230 |
/* burbujas usuario */
|
| 231 |
.chatbot-wrap .message.user,
|
| 232 |
.chatbot-wrap [data-testid="user"] {
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
}
|
| 243 |
|
| 244 |
/* ══════════════════════════════════════════
|
| 245 |
-
|
| 246 |
══════════════════════════════════════════ */
|
| 247 |
.cv-input textarea,
|
| 248 |
.cv-input input[type="text"] {
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
}
|
| 260 |
.cv-input textarea::placeholder,
|
| 261 |
.cv-input input::placeholder {
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
}
|
| 267 |
.cv-input textarea:focus,
|
| 268 |
.cv-input input:focus {
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
}
|
| 273 |
/* quitar el borde/label contenedor por defecto de Gradio */
|
| 274 |
.cv-input > .wrap { border: none !important; background: transparent !important; box-shadow: none !important; }
|
| 275 |
.cv-input label { display: none !important; }
|
| 276 |
|
| 277 |
/* ══════════════════════════════════════════
|
| 278 |
-
|
| 279 |
══════════════════════════════════════════ */
|
| 280 |
|
| 281 |
/* Enviar — primario cyan */
|
| 282 |
.btn-send {
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
}
|
| 296 |
.btn-send:hover {
|
| 297 |
-
|
| 298 |
}
|
| 299 |
.btn-send:active { transform: scale(0.97) !important; }
|
| 300 |
|
| 301 |
/* Voz — borde cyan */
|
| 302 |
.btn-voice {
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
}
|
| 315 |
.btn-voice:hover {
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
}
|
| 320 |
|
| 321 |
/* Limpiar — rojo apagado */
|
| 322 |
.btn-clear {
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
}
|
| 333 |
.btn-clear:hover {
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
}
|
| 338 |
|
| 339 |
/* Analizar PDF */
|
| 340 |
.btn-analyze {
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
}
|
| 350 |
.btn-analyze:hover { box-shadow: 0 0 32px rgba(0,212,255,0.45) !important; }
|
| 351 |
|
| 352 |
/* ══════════════════════════════════════════
|
| 353 |
-
|
| 354 |
══════════════════════════════════════════ */
|
| 355 |
.cv-mic .wrap,
|
| 356 |
.cv-audio-out .wrap {
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
}
|
| 362 |
.cv-mic label, .cv-audio-out label {
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
}
|
| 368 |
/* ocultar el componente de audio de salida de la vista (sigue funcionando) */
|
| 369 |
.cv-audio-out { visibility: hidden; height: 0; overflow: hidden; }
|
| 370 |
|
| 371 |
/* ══════════════════════════════════════════
|
| 372 |
-
|
| 373 |
══════════════════════════════════════════ */
|
| 374 |
.cv-file .wrap {
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
}
|
| 380 |
.cv-file .wrap:hover {
|
| 381 |
-
|
| 382 |
-
|
| 383 |
}
|
| 384 |
.cv-file label {
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
}
|
| 389 |
|
| 390 |
/* ══════════════════════════════════════════
|
| 391 |
-
|
| 392 |
══════════════════════════════════════════ */
|
| 393 |
.cv-row-input {
|
| 394 |
-
|
| 395 |
-
|
| 396 |
}
|
| 397 |
.cv-row-actions {
|
| 398 |
-
|
| 399 |
}
|
| 400 |
|
| 401 |
/* ══════════════════════════════════════════
|
| 402 |
-
|
| 403 |
══════════════════════════════════════════ */
|
| 404 |
#cv-statusbar {
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
}
|
| 411 |
.cv-status-dot {
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
}
|
| 417 |
@keyframes blinkDot { 0%,100%{opacity:.2} 50%{opacity:1} }
|
| 418 |
|
| 419 |
/* ══════════════════════════════════════════
|
| 420 |
-
|
| 421 |
══════════════════════════════════════════ */
|
| 422 |
/* ocultar footer de Gradio */
|
| 423 |
footer { display: none !important; }
|
|
@@ -427,284 +430,255 @@ footer { display: none !important; }
|
|
| 427 |
.gap { gap: 12px !important; }
|
| 428 |
/* columnas */
|
| 429 |
.contain { background: transparent !important; }
|
|
|
|
|
|
|
|
|
|
| 430 |
"""
|
| 431 |
|
| 432 |
# ════════════════════════════════════════════════════════════
|
| 433 |
-
# HTML: HEADER
|
| 434 |
# ════════════════════════════════════════════════════════════
|
|
|
|
| 435 |
HEADER_HTML = """
|
| 436 |
<div id="cvision-header">
|
| 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 |
-
<span style="font-family:'Share Tech Mono',monospace;font-size:0.52rem;
|
| 476 |
-
letter-spacing:0.14em;padding:3px 10px;border-radius:20px;
|
| 477 |
-
border:1px solid rgba(0,212,255,0.3);background:rgba(0,212,255,0.07);
|
| 478 |
-
color:#00d4ff;">NEURAL · ACTIVE</span>
|
| 479 |
-
</div>
|
| 480 |
</div>
|
| 481 |
<style>
|
| 482 |
-
@keyframes
|
| 483 |
@keyframes blinkDot { 0%,100%{opacity:.3} 50%{opacity:1} }
|
| 484 |
</style>
|
| 485 |
"""
|
| 486 |
|
| 487 |
NEBULA_HTML = """
|
| 488 |
-
<div id="nebula-outer"
|
| 489 |
-
gap:28px;padding:28px 32px 20px;
|
| 490 |
-
background:linear-gradient(180deg,rgba(0,212,255,0.04) 0%,transparent 100%);
|
| 491 |
-
border-bottom:1px solid rgba(0,212,255,0.14);">
|
| 492 |
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
border:1.5px solid rgba(0,212,255,0.42);
|
| 501 |
-
background:radial-gradient(circle,rgba(0,212,255,0.08) 0%,#04182e 70%);
|
| 502 |
-
box-shadow:0 0 50px rgba(0,212,255,0.22),inset 0 0 40px rgba(0,0,0,0.5);
|
| 503 |
-
overflow:hidden;position:relative;z-index:2;">
|
| 504 |
-
<canvas id="nebulaCanvas" style="width:100%;height:100%;display:block;"></canvas>
|
| 505 |
-
</div>
|
| 506 |
-
</div>
|
| 507 |
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
letter-spacing:0.12em;padding:5px 13px;border-radius:20px;
|
| 529 |
-
border:1px solid rgba(0,212,255,0.22);background:rgba(0,212,255,0.05);color:#5a8fab;">
|
| 530 |
-
PROCESAMIENTO NLP</span>
|
| 531 |
-
<span class="hero-chip" style="font-family:'Share Tech Mono',monospace;font-size:0.54rem;
|
| 532 |
-
letter-spacing:0.12em;padding:5px 13px;border-radius:20px;
|
| 533 |
-
border:1px solid rgba(0,212,255,0.22);background:rgba(0,212,255,0.05);color:#5a8fab;">
|
| 534 |
-
VISIÓN COMPUTACIONAL</span>
|
| 535 |
-
<span class="hero-chip" style="font-family:'Share Tech Mono',monospace;font-size:0.54rem;
|
| 536 |
-
letter-spacing:0.12em;padding:5px 13px;border-radius:20px;
|
| 537 |
-
border:1px solid rgba(0,212,255,0.22);background:rgba(0,212,255,0.05);color:#5a8fab;">
|
| 538 |
-
BÚSQUEDA WEB</span>
|
| 539 |
-
<span class="hero-chip" style="font-family:'Share Tech Mono',monospace;font-size:0.54rem;
|
| 540 |
-
letter-spacing:0.12em;padding:5px 13px;border-radius:20px;
|
| 541 |
-
border:1px solid rgba(0,212,255,0.22);background:rgba(0,212,255,0.05);color:#5a8fab;">
|
| 542 |
-
ANÁLISIS PDF</span>
|
| 543 |
-
<span class="hero-chip" style="font-family:'Share Tech Mono',monospace;font-size:0.54rem;
|
| 544 |
-
letter-spacing:0.12em;padding:5px 13px;border-radius:20px;
|
| 545 |
-
border:1px solid rgba(0,212,255,0.22);background:rgba(0,212,255,0.05);color:#5a8fab;">
|
| 546 |
-
VOZ</span>
|
| 547 |
-
</div>
|
| 548 |
-
</div>
|
| 549 |
</div>
|
| 550 |
"""
|
| 551 |
|
| 552 |
STATUS_BAR_HTML = """
|
| 553 |
<div id="cv-statusbar">
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
</div>
|
| 562 |
"""
|
| 563 |
|
| 564 |
# ════════════════════════════════════════════════════════════
|
| 565 |
-
# JAVASCRIPT: Nebula neural
|
| 566 |
# ════════════════════════════════════════════════════════════
|
|
|
|
| 567 |
NEBULA_JS = """
|
| 568 |
<script>
|
| 569 |
(function waitForCanvas() {
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
})();
|
| 574 |
|
| 575 |
function initNebula(cv) {
|
| 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 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
|
|
|
|
|
|
| 700 |
}
|
| 701 |
|
| 702 |
/* ── Reloj en tiempo real ── */
|
| 703 |
function updateClock() {
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
}
|
| 709 |
setInterval(updateClock, 1000);
|
| 710 |
updateClock();
|
|
@@ -712,324 +686,257 @@ updateClock();
|
|
| 712 |
"""
|
| 713 |
|
| 714 |
# ════════════════════════════════════════════════════════════
|
| 715 |
-
#
|
| 716 |
# ════════════════════════════════════════════════════════════
|
| 717 |
-
def robust_cleaner(data):
|
| 718 |
-
if data is None:
|
| 719 |
-
return ""
|
| 720 |
-
if isinstance(data, (list, tuple)):
|
| 721 |
-
if len(data) > 0:
|
| 722 |
-
last_entry = data[-1]
|
| 723 |
-
if isinstance(last_entry, (list, tuple)) and len(last_entry) == 2:
|
| 724 |
-
data = last_entry[1]
|
| 725 |
-
else:
|
| 726 |
-
data = str(last_entry)
|
| 727 |
-
else:
|
| 728 |
-
return ""
|
| 729 |
-
|
| 730 |
-
text = str(data)
|
| 731 |
-
text = text.replace("], '", "").replace("['", "").replace("']", "").replace("],", "")
|
| 732 |
-
text = re.sub(r"<generator object.*?>", "", text)
|
| 733 |
-
if "]," in text or "', '" in text:
|
| 734 |
-
parts = re.split(r"'],|',|\[", text)
|
| 735 |
-
text = parts[-1]
|
| 736 |
-
text = text.replace("(['", "").replace("'])", "")
|
| 737 |
-
text = text.replace('\\n', '\n').strip("[]()', \"")
|
| 738 |
-
text = re.sub(r"/tmp/\S+\.(mp3|wav|png|jpg)", "", text)
|
| 739 |
-
text = text.replace("boxed", "")
|
| 740 |
-
return text.strip()
|
| 741 |
|
| 742 |
-
|
| 743 |
-
#
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 753 |
"productividad": productivity_chat,
|
| 754 |
-
"cientifico":
|
| 755 |
-
"pdf":
|
| 756 |
}
|
| 757 |
-
|
| 758 |
-
|
|
|
|
| 759 |
try:
|
| 760 |
-
|
| 761 |
-
|
|
|
|
|
|
|
| 762 |
else:
|
| 763 |
-
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
|
|
|
|
|
|
|
| 770 |
else:
|
| 771 |
-
|
| 772 |
else:
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 782 |
if voice_enabled:
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
return history, "", audio_path
|
| 787 |
|
|
|
|
|
|
|
| 788 |
except Exception as e:
|
| 789 |
-
print(f"
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
def
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
|
| 809 |
-
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
with gr.
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
input_prod = gr.Textbox(
|
| 928 |
-
placeholder="¿Qué tarea quieres optimizar?",
|
| 929 |
-
show_label=False, container=False,
|
| 930 |
-
lines=1, max_lines=4, scale=8,
|
| 931 |
-
elem_classes="cv-input",
|
| 932 |
-
)
|
| 933 |
-
btn_voice_prod = gr.Button("🎙 Voz", scale=1, elem_classes="btn-voice")
|
| 934 |
-
btn_send_prod = gr.Button("Enviar ↗", scale=1, elem_classes="btn-send")
|
| 935 |
-
with gr.Row():
|
| 936 |
-
mic_prod = gr.Audio(sources=["microphone"], type="filepath",
|
| 937 |
-
label="🎤 TRANSCRIPCIÓN DE VOZ", scale=6, elem_classes="cv-mic")
|
| 938 |
-
btn_clear_prod = gr.Button("🗑 Limpiar", scale=2, elem_classes="btn-clear")
|
| 939 |
-
|
| 940 |
-
mic_prod.stop_recording(transcribe_processor, [mic_prod], [input_prod])
|
| 941 |
-
btn_send_prod.click(chat_engine_handler,
|
| 942 |
-
[chatbot_prod, input_prod, gr.State("productividad"), gr.State(False)],
|
| 943 |
-
[chatbot_prod, input_prod, out_audio_prod])
|
| 944 |
-
input_prod.submit(chat_engine_handler,
|
| 945 |
-
[chatbot_prod, input_prod, gr.State("productividad"), gr.State(False)],
|
| 946 |
-
[chatbot_prod, input_prod, out_audio_prod])
|
| 947 |
-
btn_voice_prod.click(chat_engine_handler,
|
| 948 |
-
[chatbot_prod, input_prod, gr.State("productividad"), gr.State(True)],
|
| 949 |
-
[chatbot_prod, input_prod, out_audio_prod])
|
| 950 |
-
btn_clear_prod.click(lambda: ([], "", None), None,
|
| 951 |
-
[chatbot_prod, input_prod, out_audio_prod])
|
| 952 |
-
|
| 953 |
-
# ══════════ TAB 4: CIENTÍFICO ══════════
|
| 954 |
-
with gr.Tab("🔬 Análisis Científico"):
|
| 955 |
-
chatbot_sci = gr.Chatbot(
|
| 956 |
-
height=500, bubble_full_width=False,
|
| 957 |
-
show_label=False, elem_classes="chatbot-wrap",
|
| 958 |
-
avatar_images=("assets/user_avatar.png", "assets/CVision logo.png"),
|
| 959 |
-
)
|
| 960 |
-
out_audio_sci = gr.Audio(visible=False, autoplay=True, elem_classes="cv-audio-out")
|
| 961 |
-
with gr.Row():
|
| 962 |
-
input_sci = gr.Textbox(
|
| 963 |
-
placeholder="Ingresa tu consulta científica o fórmula...",
|
| 964 |
-
show_label=False, container=False,
|
| 965 |
-
lines=1, max_lines=4, scale=8,
|
| 966 |
-
elem_classes="cv-input",
|
| 967 |
-
)
|
| 968 |
-
btn_voice_sci = gr.Button("🎙 Voz", scale=1, elem_classes="btn-voice")
|
| 969 |
-
btn_send_sci = gr.Button("Analizar ↗", scale=1, elem_classes="btn-send")
|
| 970 |
-
with gr.Row():
|
| 971 |
-
mic_sci = gr.Audio(sources=["microphone"], type="filepath",
|
| 972 |
-
label="🎤 TRANSCRIPCIÓN DE VOZ", scale=6, elem_classes="cv-mic")
|
| 973 |
-
btn_clear_sci = gr.Button("🗑 Limpiar", scale=2, elem_classes="btn-clear")
|
| 974 |
-
|
| 975 |
-
mic_sci.stop_recording(transcribe_processor, [mic_sci], [input_sci])
|
| 976 |
-
btn_send_sci.click(chat_engine_handler,
|
| 977 |
-
[chatbot_sci, input_sci, gr.State("cientifico"), gr.State(False)],
|
| 978 |
-
[chatbot_sci, input_sci, out_audio_sci])
|
| 979 |
-
input_sci.submit(chat_engine_handler,
|
| 980 |
-
[chatbot_sci, input_sci, gr.State("cientifico"), gr.State(False)],
|
| 981 |
-
[chatbot_sci, input_sci, out_audio_sci])
|
| 982 |
-
btn_voice_sci.click(chat_engine_handler,
|
| 983 |
-
[chatbot_sci, input_sci, gr.State("cientifico"), gr.State(True)],
|
| 984 |
-
[chatbot_sci, input_sci, out_audio_sci])
|
| 985 |
-
btn_clear_sci.click(lambda: ([], "", None), None,
|
| 986 |
-
[chatbot_sci, input_sci, out_audio_sci])
|
| 987 |
-
|
| 988 |
-
# ══════════ TAB 5: ANALISTA PDF ══════════
|
| 989 |
-
with gr.Tab("📄 Analista PDF"):
|
| 990 |
-
file_input = gr.File(
|
| 991 |
-
label="📂 CARGAR DOCUMENTO PDF",
|
| 992 |
-
file_types=[".pdf"],
|
| 993 |
-
elem_classes="cv-file",
|
| 994 |
-
)
|
| 995 |
-
chatbot_pdf = gr.Chatbot(
|
| 996 |
-
height=440, bubble_full_width=False,
|
| 997 |
-
show_label=False, elem_classes="chatbot-wrap",
|
| 998 |
-
avatar_images=("assets/user_avatar.png", "assets/CVision logo.png"),
|
| 999 |
-
)
|
| 1000 |
-
out_audio_pdf = gr.Audio(visible=False, autoplay=True, elem_classes="cv-audio-out")
|
| 1001 |
-
with gr.Row():
|
| 1002 |
-
input_pdf = gr.Textbox(
|
| 1003 |
-
placeholder="Pregunta algo sobre el documento cargado...",
|
| 1004 |
-
show_label=False, container=False,
|
| 1005 |
-
lines=1, max_lines=4, scale=8,
|
| 1006 |
-
elem_classes="cv-input",
|
| 1007 |
-
)
|
| 1008 |
-
btn_voice_pdf = gr.Button("🎙 Voz", scale=1, elem_classes="btn-voice")
|
| 1009 |
-
btn_send_pdf = gr.Button("Analizar ↗", scale=1, elem_classes="btn-analyze")
|
| 1010 |
-
with gr.Row():
|
| 1011 |
-
mic_pdf = gr.Audio(sources=["microphone"], type="filepath",
|
| 1012 |
-
label="🎤 TRANSCRIPCIÓN DE VOZ", scale=6, elem_classes="cv-mic")
|
| 1013 |
-
btn_clear_pdf = gr.Button("🗑 Limpiar", scale=2, elem_classes="btn-clear")
|
| 1014 |
-
|
| 1015 |
-
mic_pdf.stop_recording(transcribe_processor, [mic_pdf], [input_pdf])
|
| 1016 |
-
btn_send_pdf.click(chat_engine_handler,
|
| 1017 |
-
[chatbot_pdf, input_pdf, gr.State("pdf"), gr.State(False), file_input],
|
| 1018 |
-
[chatbot_pdf, input_pdf, out_audio_pdf])
|
| 1019 |
-
input_pdf.submit(chat_engine_handler,
|
| 1020 |
-
[chatbot_pdf, input_pdf, gr.State("pdf"), gr.State(False), file_input],
|
| 1021 |
-
[chatbot_pdf, input_pdf, out_audio_pdf])
|
| 1022 |
-
btn_voice_pdf.click(chat_engine_handler,
|
| 1023 |
-
[chatbot_pdf, input_pdf, gr.State("pdf"), gr.State(True), file_input],
|
| 1024 |
-
[chatbot_pdf, input_pdf, out_audio_pdf])
|
| 1025 |
-
btn_clear_pdf.click(lambda: ([], "", None), None,
|
| 1026 |
-
[chatbot_pdf, input_pdf, out_audio_pdf])
|
| 1027 |
-
|
| 1028 |
-
# ════════════════════════════════════════════════════════════
|
| 1029 |
-
# LANZAMIENTO
|
| 1030 |
-
# ════════════════════════════════════════════════════════════
|
| 1031 |
if __name__ == "__main__":
|
|
|
|
| 1032 |
assistant.launch(
|
| 1033 |
show_error=True,
|
| 1034 |
-
favicon_path="assets/CVision logo.png"
|
| 1035 |
)
|
|
|
|
| 3 |
import os
|
| 4 |
import time
|
| 5 |
import json
|
| 6 |
+
from datetime import datetime
|
| 7 |
from modules.listen import transcribe_audio_file
|
| 8 |
from modules.talker.talk import speak
|
| 9 |
|
|
|
|
| 14 |
browser_chat,
|
| 15 |
scientist_chat,
|
| 16 |
regular_chat,
|
| 17 |
+
document_chat
|
| 18 |
)
|
| 19 |
except ImportError:
|
| 20 |
+
print("Error: No se pudieron importar los módulos de chat. Asegúrate de que 'modules' esté en el path.")
|
| 21 |
|
| 22 |
# ════════════════════════════════════════════════════════════
|
| 23 |
+
# CSS FUTURISTA — Diamante × Cyan (Fusionado y Adaptado)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# ════════════════════════════════════════════════════════════
|
| 25 |
CUSTOM_CSS = """
|
| 26 |
/* ── Google Fonts ── */
|
|
|
|
| 28 |
|
| 29 |
/* ── Variables globales ── */
|
| 30 |
:root {
|
| 31 |
+
--c0: #000509;
|
| 32 |
+
--c1: #020c18;
|
| 33 |
+
--c2: #04182e;
|
| 34 |
+
--cyan: #00d4ff;
|
| 35 |
+
--cyan2: #00a8e8;
|
| 36 |
+
--cyan-dim: rgba(0,212,255,0.10);
|
| 37 |
+
--diamond: #e8f4ff;
|
| 38 |
+
--diamond2: #b8d8f0;
|
| 39 |
+
--text-main: #cce9f8;
|
| 40 |
+
--text-muted: #5a8fab;
|
| 41 |
+
--text-dim: #2a4a60;
|
| 42 |
+
--border: rgba(0,212,255,0.16);
|
| 43 |
+
--border-bright: rgba(0,212,255,0.45);
|
| 44 |
+
--glass: rgba(4,24,46,0.78);
|
| 45 |
+
--glass2: rgba(2,12,24,0.90);
|
| 46 |
+
--radius: 12px;
|
| 47 |
+
--radius-lg: 20px;
|
| 48 |
+
--font-d: 'Orbitron', monospace;
|
| 49 |
+
--font-b: 'Exo 2', sans-serif;
|
| 50 |
+
--font-m: 'Share Tech Mono', monospace;
|
| 51 |
}
|
| 52 |
|
| 53 |
/* ── Reset base ── */
|
| 54 |
*, *::before, *::after { box-sizing: border-box; }
|
| 55 |
body, .gradio-container {
|
| 56 |
+
background: var(--c0) !important;
|
| 57 |
+
color: var(--text-main) !important;
|
| 58 |
+
font-family: var(--font-b) !important;
|
| 59 |
+
min-height: 100vh;
|
| 60 |
+
margin: 0 !important;
|
| 61 |
}
|
| 62 |
|
| 63 |
/* scrollbar */
|
|
|
|
| 67 |
|
| 68 |
/* ── Grid de fondo ── */
|
| 69 |
.gradio-container::before {
|
| 70 |
+
content: '';
|
| 71 |
+
position: fixed; inset: 0; z-index: 0; pointer-events: none;
|
| 72 |
+
background-image:
|
| 73 |
+
linear-gradient(rgba(0,212,255,0.028) 1px, transparent 1px),
|
| 74 |
+
linear-gradient(90deg, rgba(0,212,255,0.028) 1px, transparent 1px);
|
| 75 |
+
background-size: 44px 44px;
|
| 76 |
+
mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 0%, transparent 100%);
|
| 77 |
}
|
| 78 |
|
| 79 |
/* ── Scanline animado ── */
|
| 80 |
.gradio-container::after {
|
| 81 |
+
content: '';
|
| 82 |
+
position: fixed; top: 0; left: 0; width: 100%; height: 2px;
|
| 83 |
+
background: linear-gradient(90deg, transparent, rgba(0,212,255,0.3), transparent);
|
| 84 |
+
animation: scanDown 7s ease-in-out infinite;
|
| 85 |
+
z-index: 9999; pointer-events: none;
|
| 86 |
}
|
| 87 |
@keyframes scanDown {
|
| 88 |
+
0% { top: -2px; opacity: 0; }
|
| 89 |
+
8% { opacity: 1; }
|
| 90 |
+
92% { opacity: .4; }
|
| 91 |
+
100% { top: 100vh; opacity: 0; }
|
| 92 |
}
|
| 93 |
|
| 94 |
/* ══════════════════════════════════════════
|
| 95 |
+
HEADER / TÍTULO PRINCIPAL (Imagen 7)
|
| 96 |
══════════════════════════════════��═══════ */
|
| 97 |
#cvision-header {
|
| 98 |
+
background: var(--glass2);
|
| 99 |
+
border-bottom: 1px solid var(--border);
|
| 100 |
+
padding: 18px 32px;
|
| 101 |
+
display: flex;
|
| 102 |
+
align-items: center;
|
| 103 |
+
gap: 18px;
|
| 104 |
+
position: sticky; top: 0; z-index: 100;
|
| 105 |
+
backdrop-filter: blur(20px);
|
| 106 |
+
width: 100%;
|
| 107 |
}
|
| 108 |
|
| 109 |
+
/* ══════════════════════════════════════════
|
| 110 |
+
NEBULA HERO SECTION (Imagen 8)
|
| 111 |
+
══════════════════════════════════════════ */
|
| 112 |
#nebula-outer {
|
| 113 |
+
display: flex;
|
| 114 |
+
justify-content: center;
|
| 115 |
+
align-items: flex-start;
|
| 116 |
+
gap: 28px;
|
| 117 |
+
padding: 28px 32px 20px;
|
| 118 |
+
background: linear-gradient(180deg, rgba(0,212,255,0.04) 0%, transparent 100%);
|
| 119 |
+
border-bottom: 1px solid var(--border);
|
| 120 |
}
|
| 121 |
+
|
| 122 |
#nebula-ring-wrap {
|
| 123 |
+
position: relative;
|
| 124 |
+
width: 230px; height: 230px;
|
| 125 |
+
flex-shrink: 0;
|
| 126 |
}
|
| 127 |
#nebula-canvas-wrap {
|
| 128 |
+
width: 230px; height: 230px;
|
| 129 |
+
border-radius: 50%;
|
| 130 |
+
border: 1.5px solid rgba(0,212,255,0.4);
|
| 131 |
+
background: radial-gradient(circle, rgba(0,212,255,0.08) 0%, #04182e 70%);
|
| 132 |
+
box-shadow: 0 0 50px rgba(0,212,255,0.22), inset 0 0 40px rgba(0,0,0,0.5);
|
| 133 |
+
overflow: hidden;
|
| 134 |
+
position: relative; z-index: 2;
|
| 135 |
}
|
| 136 |
#nebulaCanvas { width: 100%; height: 100%; display: block; }
|
| 137 |
|
| 138 |
/* anillos externos decorativos */
|
| 139 |
.nebula-deco-ring {
|
| 140 |
+
position: absolute; border-radius: 50%; pointer-events: none;
|
| 141 |
+
border: 0.5px solid rgba(0,212,255,0.13);
|
| 142 |
}
|
| 143 |
.nebula-deco-ring.r1 { inset: -20px; animation: spin 18s linear infinite; }
|
| 144 |
.nebula-deco-ring.r2 { inset: -38px; border-style: dashed; animation: spin 30s linear infinite reverse; }
|
|
|
|
| 146 |
|
| 147 |
/* hero info al lado de la nebula */
|
| 148 |
#nebula-info {
|
| 149 |
+
display: flex; flex-direction: column; gap: 12px;
|
| 150 |
+
padding: 10px 0 0 0; max-width: 540px;
|
| 151 |
}
|
| 152 |
.hero-eyebrow {
|
| 153 |
+
font-family: var(--font-m); font-size: 0.58rem;
|
| 154 |
+
letter-spacing: 0.3em; color: var(--text-muted);
|
| 155 |
+
text-transform: uppercase;
|
| 156 |
}
|
| 157 |
.hero-title {
|
| 158 |
+
font-family: var(--font-d); font-size: 2.1rem;
|
| 159 |
+
font-weight: 900; line-height: 1.15;
|
| 160 |
+
color: var(--diamond);
|
| 161 |
+
text-shadow: 0 0 30px rgba(0,212,255,0.4);
|
| 162 |
}
|
| 163 |
.hero-title .accent {
|
| 164 |
+
color: transparent;
|
| 165 |
+
background: linear-gradient(135deg, #00d4ff 0%, #e8f4ff 50%, #00a8e8 100%);
|
| 166 |
+
-webkit-background-clip: text; background-clip: text;
|
| 167 |
}
|
| 168 |
.hero-desc {
|
| 169 |
+
font-size: 0.83rem; color: var(--text-muted);
|
| 170 |
+
line-height: 1.7; font-weight: 300;
|
| 171 |
}
|
| 172 |
.hero-chips { display: flex; flex-wrap: wrap; gap: 7px; }
|
| 173 |
.hero-chip {
|
| 174 |
+
font-family: var(--font-m); font-size: 0.54rem;
|
| 175 |
+
letter-spacing: 0.12em; padding: 5px 13px;
|
| 176 |
+
border-radius: 20px; border: 1px solid rgba(0,212,255,0.22);
|
| 177 |
+
background: rgba(0,212,255,0.05); color: var(--text-muted);
|
| 178 |
}
|
| 179 |
|
| 180 |
/* ══════════════════════════════════════════
|
| 181 |
+
TABS — barra de navegación principal
|
| 182 |
══════════════════════════════════════════ */
|
| 183 |
.tab-nav {
|
| 184 |
+
background: var(--glass2) !important;
|
| 185 |
+
border-bottom: 1px solid var(--border) !important;
|
| 186 |
+
backdrop-filter: blur(10px);
|
| 187 |
+
padding: 0 20px !important;
|
| 188 |
+
gap: 0 !important;
|
| 189 |
}
|
| 190 |
.tab-nav button {
|
| 191 |
+
font-family: var(--font-b) !important;
|
| 192 |
+
font-size: 0.8rem !important;
|
| 193 |
+
font-weight: 500 !important;
|
| 194 |
+
letter-spacing: 0.05em !important;
|
| 195 |
+
color: var(--text-muted) !important;
|
| 196 |
+
background: transparent !important;
|
| 197 |
+
border: none !important;
|
| 198 |
+
border-bottom: 2px solid transparent !important;
|
| 199 |
+
border-radius: 0 !important;
|
| 200 |
+
padding: 14px 22px !important;
|
| 201 |
+
transition: color 0.2s, border-color 0.2s !important;
|
| 202 |
}
|
| 203 |
.tab-nav button:hover { color: var(--diamond2) !important; }
|
| 204 |
.tab-nav button.selected {
|
| 205 |
+
color: var(--cyan) !important;
|
| 206 |
+
border-bottom-color: var(--cyan) !important;
|
| 207 |
+
background: transparent !important;
|
| 208 |
}
|
| 209 |
|
| 210 |
/* ══════════════════════════════════════════
|
| 211 |
+
CHATBOT — ventana de mensajes (Imagen 9)
|
| 212 |
══════════════════════════════════════════ */
|
| 213 |
.chatbot-wrap .wrap {
|
| 214 |
+
background: rgba(4,24,46,0.78) !important;
|
| 215 |
+
border: 1px solid var(--border) !important;
|
| 216 |
+
border-radius: var(--radius-lg) !important;
|
| 217 |
+
backdrop-filter: blur(12px) !important;
|
| 218 |
+
box-shadow: inset 0 0 40px rgba(0,0,0,0.3), 0 0 30px rgba(0,212,255,0.08) !important;
|
| 219 |
}
|
| 220 |
/* burbujas bot */
|
| 221 |
.chatbot-wrap .message.bot,
|
| 222 |
.chatbot-wrap [data-testid="bot"] {
|
| 223 |
+
background: linear-gradient(135deg, rgba(4,24,46,0.92), rgba(6,29,54,0.88)) !important;
|
| 224 |
+
border: 1px solid rgba(0,212,255,0.14) !important;
|
| 225 |
+
border-radius: 4px 18px 18px 18px !important;
|
| 226 |
+
color: var(--text-main) !important;
|
| 227 |
+
font-family: var(--font-b) !important;
|
| 228 |
+
font-size: 0.85rem !important;
|
| 229 |
+
box-shadow: 0 4px 18px rgba(0,0,0,0.3) !important;
|
| 230 |
+
padding: 13px 17px !important;
|
| 231 |
+
margin-right: 12% !important;
|
| 232 |
}
|
| 233 |
/* burbujas usuario */
|
| 234 |
.chatbot-wrap .message.user,
|
| 235 |
.chatbot-wrap [data-testid="user"] {
|
| 236 |
+
background: linear-gradient(135deg, rgba(0,70,120,0.72), rgba(0,50,100,0.82)) !important;
|
| 237 |
+
border: 1px solid rgba(0,160,230,0.22) !important;
|
| 238 |
+
border-radius: 18px 4px 18px 18px !important;
|
| 239 |
+
color: var(--diamond) !important;
|
| 240 |
+
font-family: var(--font-b) !important;
|
| 241 |
+
font-size: 0.85rem !important;
|
| 242 |
+
box-shadow: 0 4px 18px rgba(0,0,0,0.3) !important;
|
| 243 |
+
padding: 13px 17px !important;
|
| 244 |
+
margin-left: 12% !important;
|
| 245 |
}
|
| 246 |
|
| 247 |
/* ══════════════════════════════════════════
|
| 248 |
+
TEXTBOX — campo de entrada
|
| 249 |
══════════════════════════════════════════ */
|
| 250 |
.cv-input textarea,
|
| 251 |
.cv-input input[type="text"] {
|
| 252 |
+
background: rgba(4,24,46,0.82) !important;
|
| 253 |
+
border: 1px solid rgba(0,212,255,0.18) !important;
|
| 254 |
+
border-radius: var(--radius) !important;
|
| 255 |
+
color: var(--text-main) !important;
|
| 256 |
+
font-family: var(--font-b) !important;
|
| 257 |
+
font-size: 0.85rem !important;
|
| 258 |
+
padding: 13px 16px !important;
|
| 259 |
+
transition: border-color 0.2s, box-shadow 0.2s !important;
|
| 260 |
+
caret-color: var(--cyan) !important;
|
| 261 |
+
resize: none !important;
|
| 262 |
}
|
| 263 |
.cv-input textarea::placeholder,
|
| 264 |
.cv-input input::placeholder {
|
| 265 |
+
color: var(--text-dim) !important;
|
| 266 |
+
font-family: var(--font-m) !important;
|
| 267 |
+
font-size: 0.72rem !important;
|
| 268 |
+
letter-spacing: 0.08em !important;
|
| 269 |
}
|
| 270 |
.cv-input textarea:focus,
|
| 271 |
.cv-input input:focus {
|
| 272 |
+
border-color: rgba(0,212,255,0.48) !important;
|
| 273 |
+
box-shadow: 0 0 18px rgba(0,212,255,0.1) !important;
|
| 274 |
+
outline: none !important;
|
| 275 |
}
|
| 276 |
/* quitar el borde/label contenedor por defecto de Gradio */
|
| 277 |
.cv-input > .wrap { border: none !important; background: transparent !important; box-shadow: none !important; }
|
| 278 |
.cv-input label { display: none !important; }
|
| 279 |
|
| 280 |
/* ══════════════════════════════════════════
|
| 281 |
+
BOTONES (Imagen 10)
|
| 282 |
══════════════════════════════════════════ */
|
| 283 |
|
| 284 |
/* Enviar — primario cyan */
|
| 285 |
.btn-send {
|
| 286 |
+
background: linear-gradient(135deg, #004a7c, #0070b8, #00a8e8) !important;
|
| 287 |
+
color: #fff !important;
|
| 288 |
+
border: none !important;
|
| 289 |
+
border-radius: var(--radius) !important;
|
| 290 |
+
font-family: var(--font-b) !important;
|
| 291 |
+
font-weight: 600 !important;
|
| 292 |
+
font-size: 0.8rem !important;
|
| 293 |
+
letter-spacing: 0.08em !important;
|
| 294 |
+
padding: 0 22px !important;
|
| 295 |
+
min-height: 48px !important;
|
| 296 |
+
box-shadow: 0 0 20px rgba(0,168,232,0.28), inset 0 1px 0 rgba(255,255,255,0.12) !important;
|
| 297 |
+
transition: box-shadow 0.2s, transform 0.15s !important;
|
| 298 |
}
|
| 299 |
.btn-send:hover {
|
| 300 |
+
box-shadow: 0 0 32px rgba(0,212,255,0.45) !important;
|
| 301 |
}
|
| 302 |
.btn-send:active { transform: scale(0.97) !important; }
|
| 303 |
|
| 304 |
/* Voz — borde cyan */
|
| 305 |
.btn-voice {
|
| 306 |
+
background: transparent !important;
|
| 307 |
+
border: 1px solid rgba(0,212,255,0.32) !important;
|
| 308 |
+
color: var(--cyan) !important;
|
| 309 |
+
border-radius: var(--radius) !important;
|
| 310 |
+
font-family: var(--font-b) !important;
|
| 311 |
+
font-weight: 500 !important;
|
| 312 |
+
font-size: 0.78rem !important;
|
| 313 |
+
letter-spacing: 0.06em !important;
|
| 314 |
+
min-height: 48px !important;
|
| 315 |
+
padding: 0 18px !important;
|
| 316 |
+
transition: all 0.2s !important;
|
| 317 |
}
|
| 318 |
.btn-voice:hover {
|
| 319 |
+
background: var(--cyan-dim) !important;
|
| 320 |
+
border-color: var(--border-bright) !important;
|
| 321 |
+
box-shadow: 0 0 14px rgba(0,212,255,0.2) !important;
|
| 322 |
}
|
| 323 |
|
| 324 |
/* Limpiar — rojo apagado */
|
| 325 |
.btn-clear {
|
| 326 |
+
background: transparent !important;
|
| 327 |
+
border: 1px solid rgba(255,60,80,0.2) !important;
|
| 328 |
+
color: rgba(255,100,120,0.65) !important;
|
| 329 |
+
border-radius: var(--radius) !important;
|
| 330 |
+
font-family: var(--font-b) !important;
|
| 331 |
+
font-size: 0.75rem !important;
|
| 332 |
+
min-height: 40px !important;
|
| 333 |
+
padding: 0 16px !important;
|
| 334 |
+
transition: all 0.2s !important;
|
| 335 |
}
|
| 336 |
.btn-clear:hover {
|
| 337 |
+
border-color: rgba(255,60,80,0.45) !important;
|
| 338 |
+
background: rgba(255,60,80,0.06) !important;
|
| 339 |
+
color: #ff6477 !important;
|
| 340 |
}
|
| 341 |
|
| 342 |
/* Analizar PDF */
|
| 343 |
.btn-analyze {
|
| 344 |
+
background: linear-gradient(135deg, #004a7c, #0070b8, #00a8e8) !important;
|
| 345 |
+
color: #fff !important; border: none !important;
|
| 346 |
+
border-radius: var(--radius) !important;
|
| 347 |
+
font-family: var(--font-b) !important;
|
| 348 |
+
font-weight: 600 !important; font-size: 0.8rem !important;
|
| 349 |
+
padding: 0 22px !important; min-height: 48px !important;
|
| 350 |
+
box-shadow: 0 0 20px rgba(0,168,232,0.28) !important;
|
| 351 |
+
transition: box-shadow 0.2s !important;
|
| 352 |
}
|
| 353 |
.btn-analyze:hover { box-shadow: 0 0 32px rgba(0,212,255,0.45) !important; }
|
| 354 |
|
| 355 |
/* ══════════════════════════════════════════
|
| 356 |
+
AUDIO — micrófono / salida
|
| 357 |
══════════════════════════════════════════ */
|
| 358 |
.cv-mic .wrap,
|
| 359 |
.cv-audio-out .wrap {
|
| 360 |
+
background: rgba(4,24,46,0.6) !important;
|
| 361 |
+
border: 1px solid var(--border) !important;
|
| 362 |
+
border-radius: var(--radius) !important;
|
| 363 |
+
color: var(--text-muted) !important;
|
| 364 |
}
|
| 365 |
.cv-mic label, .cv-audio-out label {
|
| 366 |
+
font-family: var(--font-m) !important;
|
| 367 |
+
font-size: 0.58rem !important;
|
| 368 |
+
letter-spacing: 0.18em !important;
|
| 369 |
+
color: var(--text-dim) !important;
|
| 370 |
}
|
| 371 |
/* ocultar el componente de audio de salida de la vista (sigue funcionando) */
|
| 372 |
.cv-audio-out { visibility: hidden; height: 0; overflow: hidden; }
|
| 373 |
|
| 374 |
/* ══════════════════════════════════════════
|
| 375 |
+
FILE UPLOAD — analista PDF
|
| 376 |
══════════════════════════════════════════ */
|
| 377 |
.cv-file .wrap {
|
| 378 |
+
background: rgba(4,24,46,0.6) !important;
|
| 379 |
+
border: 1.5px dashed rgba(0,212,255,0.22) !important;
|
| 380 |
+
border-radius: var(--radius-lg) !important;
|
| 381 |
+
transition: border-color 0.25s, background 0.25s !important;
|
| 382 |
}
|
| 383 |
.cv-file .wrap:hover {
|
| 384 |
+
border-color: rgba(0,212,255,0.5) !important;
|
| 385 |
+
background: rgba(0,212,255,0.05) !important;
|
| 386 |
}
|
| 387 |
.cv-file label {
|
| 388 |
+
font-family: var(--font-m) !important;
|
| 389 |
+
font-size: 0.6rem !important; letter-spacing: 0.18em !important;
|
| 390 |
+
color: var(--text-muted) !important;
|
| 391 |
}
|
| 392 |
|
| 393 |
/* ══════════════════════════════════════════
|
| 394 |
+
SEPARADORES DE FILAS
|
| 395 |
══════════════════════════════════════════ */
|
| 396 |
.cv-row-input {
|
| 397 |
+
display: flex; gap: 10px; align-items: flex-end;
|
| 398 |
+
padding: 0 !important;
|
| 399 |
}
|
| 400 |
.cv-row-actions {
|
| 401 |
+
display: flex; gap: 8px; align-items: center;
|
| 402 |
}
|
| 403 |
|
| 404 |
/* ══════════════════════════════════════════
|
| 405 |
+
ESTADO DEL SISTEMA — barra inferior
|
| 406 |
══════════════════════════════════════════ */
|
| 407 |
#cv-statusbar {
|
| 408 |
+
position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
|
| 409 |
+
font-family: var(--font-m); font-size: 0.52rem; letter-spacing: 0.18em;
|
| 410 |
+
color: rgba(0,212,255,0.3);
|
| 411 |
+
display: flex; align-items: center; gap: 18px;
|
| 412 |
+
pointer-events: none; z-index: 500;
|
| 413 |
}
|
| 414 |
.cv-status-dot {
|
| 415 |
+
width: 5px; height: 5px; border-radius: 50%;
|
| 416 |
+
background: rgba(0,212,255,0.4);
|
| 417 |
+
animation: blinkDot 2s ease-in-out infinite;
|
| 418 |
+
display: inline-block;
|
| 419 |
}
|
| 420 |
@keyframes blinkDot { 0%,100%{opacity:.2} 50%{opacity:1} }
|
| 421 |
|
| 422 |
/* ══════════════════════════════════════════
|
| 423 |
+
MISCELÁNEOS GRADIO
|
| 424 |
══════════════════════════════════════════ */
|
| 425 |
/* ocultar footer de Gradio */
|
| 426 |
footer { display: none !important; }
|
|
|
|
| 430 |
.gap { gap: 12px !important; }
|
| 431 |
/* columnas */
|
| 432 |
.contain { background: transparent !important; }
|
| 433 |
+
|
| 434 |
+
/* Ajustes específicos para los componentes contenedores de Gradio */
|
| 435 |
+
.gradio-container .block { background: transparent !important; border: none !important; box-shadow: none !important; }
|
| 436 |
"""
|
| 437 |
|
| 438 |
# ════════════════════════════════════════════════════════════
|
| 439 |
+
# HTML: HEADER (Imagen 7) + NEBULA (Imagen 8) + STATUS BAR
|
| 440 |
# ════════════════════════════════════════════════════════════
|
| 441 |
+
# Nota: He adaptado el HEADER_HTML para usar la imagen del logo original PNG.
|
| 442 |
HEADER_HTML = """
|
| 443 |
<div id="cvision-header">
|
| 444 |
+
<div style="width:52px;height:52px;border-radius:50%;
|
| 445 |
+
border:1.5px solid rgba(0,212,255,0.5);
|
| 446 |
+
background:radial-gradient(circle,rgba(0,212,255,0.15) 0%,#04182e 100%);
|
| 447 |
+
display:flex;align-items:center;justify-content:center;
|
| 448 |
+
box-shadow:0 0 20px rgba(0,212,255,0.35);
|
| 449 |
+
position:relative;overflow:hidden;flex-shrink:0;">
|
| 450 |
+
<img src="file/assets/CVision logo.png" style="width:80%; height:80%; object-fit:contain; position:relative; z-index:1;" alt="CV">
|
| 451 |
+
<div style="position:absolute;inset:-50%;width:200%;height:200%;
|
| 452 |
+
background:conic-gradient(from 0deg,transparent 60%,rgba(0,212,255,0.2) 80%,transparent 100%);
|
| 453 |
+
animation:spinHeaderConic 4s linear infinite;"></div>
|
| 454 |
+
</div>
|
| 455 |
+
<div style="flex:1">
|
| 456 |
+
<div style="font-family:'Orbitron',monospace;font-size:1.45rem;font-weight:900;
|
| 457 |
+
color:#fff;letter-spacing:0.12em;
|
| 458 |
+
text-shadow:0 0 20px rgba(0,212,255,0.6);">
|
| 459 |
+
Asistente Virtual C<span style="color:#00d4ff">Vision</span>
|
| 460 |
+
</div>
|
| 461 |
+
<div style="font-family:'Share Tech Mono',monospace;font-size:0.58rem;
|
| 462 |
+
letter-spacing:0.22em;color:#5a8fab;margin-top:4px;">
|
| 463 |
+
NÚCLEO COGNITIVO MULTIMODAL · CRISTIAN VELASCO
|
| 464 |
+
</div>
|
| 465 |
+
</div>
|
| 466 |
+
<div style="display:flex;gap:8px;align-items:center">
|
| 467 |
+
<div style="width:7px;height:7px;border-radius:50%;background:#00ff96;
|
| 468 |
+
box-shadow:0 0 8px #00ff96;animation:blinkDot 2s ease-in-out infinite;"></div>
|
| 469 |
+
<span style="font-family:'Share Tech Mono',monospace;font-size:0.52rem;
|
| 470 |
+
letter-spacing:0.14em;padding:3px 10px;border-radius:20px;
|
| 471 |
+
border:1px solid rgba(0,255,150,0.3);background:rgba(0,255,150,0.07);
|
| 472 |
+
color:#00ff96;">ONLINE</span>
|
| 473 |
+
<span style="font-family:'Share Tech Mono',monospace;font-size:0.52rem;
|
| 474 |
+
letter-spacing:0.14em;padding:3px 10px;border-radius:20px;
|
| 475 |
+
border:1px solid rgba(0,212,255,0.3);background:rgba(0,212,255,0.07);
|
| 476 |
+
color:#00d4ff;">v3.2.1</span>
|
| 477 |
+
<span style="font-family:'Share Tech Mono',monospace;font-size:0.52rem;
|
| 478 |
+
letter-spacing:0.14em;padding:3px 10px;border-radius:20px;
|
| 479 |
+
border:1px solid rgba(0,212,255,0.3);background:rgba(0,212,255,0.07);
|
| 480 |
+
color:#00d4ff;">NEURAL · ACTIVE</span>
|
| 481 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
</div>
|
| 483 |
<style>
|
| 484 |
+
@keyframes spinHeaderConic { to { transform: rotate(360deg); } }
|
| 485 |
@keyframes blinkDot { 0%,100%{opacity:.3} 50%{opacity:1} }
|
| 486 |
</style>
|
| 487 |
"""
|
| 488 |
|
| 489 |
NEBULA_HTML = """
|
| 490 |
+
<div id="nebula-outer">
|
|
|
|
|
|
|
|
|
|
| 491 |
|
| 492 |
+
<div id="nebula-ring-wrap">
|
| 493 |
+
<div class="nebula-deco-ring r1"></div>
|
| 494 |
+
<div class="nebula-deco-ring r2"></div>
|
| 495 |
+
<div id="nebula-canvas-wrap">
|
| 496 |
+
<canvas id="nebulaCanvas"></canvas>
|
| 497 |
+
</div>
|
| 498 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 499 |
|
| 500 |
+
<div id="nebula-info">
|
| 501 |
+
<div class="hero-eyebrow">
|
| 502 |
+
// SISTEMA ACTIVADO · CORE OPERATIVO
|
| 503 |
+
</div>
|
| 504 |
+
<div class="hero-title">
|
| 505 |
+
Asistente Virtual<br>
|
| 506 |
+
<span class="accent">CVision</span>
|
| 507 |
+
</div>
|
| 508 |
+
<div class="hero-desc">
|
| 509 |
+
Interfaz de inteligencia artificial multimodal. Combina procesamiento de lenguaje natural,
|
| 510 |
+
análisis de documentos y búsqueda web en un solo núcleo cognitivo.
|
| 511 |
+
</div>
|
| 512 |
+
<div class="hero-chips">
|
| 513 |
+
<span class="hero-chip">PROCESAMIENTO NLP</span>
|
| 514 |
+
<span class="hero-chip">VISIÓN COMPUTACIONAL</span>
|
| 515 |
+
<span class="hero-chip">BÚSQUEDA WEB</span>
|
| 516 |
+
<span class="hero-chip">ANÁLISIS PDF</span>
|
| 517 |
+
<span class="hero-chip">VOZ</span>
|
| 518 |
+
</div>
|
| 519 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
</div>
|
| 521 |
"""
|
| 522 |
|
| 523 |
STATUS_BAR_HTML = """
|
| 524 |
<div id="cv-statusbar">
|
| 525 |
+
<span>CORE ACTIVE</span>
|
| 526 |
+
<span class="cv-status-dot"></span>
|
| 527 |
+
<span>ALL SYSTEMS NOMINAL</span>
|
| 528 |
+
<span class="cv-status-dot" style="animation-delay:.6s"></span>
|
| 529 |
+
<span id="cv-clock" style="min-width:64px;text-align:center;">00:00:00</span>
|
| 530 |
+
<span class="cv-status-dot" style="animation-delay:1.2s"></span>
|
| 531 |
+
<span>SCANNING</span>
|
| 532 |
</div>
|
| 533 |
"""
|
| 534 |
|
| 535 |
# ════════════════════════════════════════════════════════════
|
| 536 |
+
# JAVASCRIPT: Nebula neural (Optimizada) + Reloj
|
| 537 |
# ════════════════════════════════════════════════════════════
|
| 538 |
+
# Nota: He optimizado la nébula para que sea más fluida y consuma menos recursos.
|
| 539 |
NEBULA_JS = """
|
| 540 |
<script>
|
| 541 |
(function waitForCanvas() {
|
| 542 |
+
const cv = document.getElementById('nebulaCanvas');
|
| 543 |
+
if (!cv) { setTimeout(waitForCanvas, 300); return; }
|
| 544 |
+
initNebula(cv);
|
| 545 |
})();
|
| 546 |
|
| 547 |
function initNebula(cv) {
|
| 548 |
+
const ctx = cv.getContext('2d');
|
| 549 |
+
let W, H, cx, cy, neurons = [], pulses = [], synapses = [], pulseTimer = 0;
|
| 550 |
+
// Optimizamos la cantidad de neuronas y conexiones para fluidez
|
| 551 |
+
const N = 36, CONN = 65;
|
| 552 |
+
|
| 553 |
+
function resize() {
|
| 554 |
+
W = cv.width = cv.offsetWidth || 230;
|
| 555 |
+
H = cv.height = cv.offsetHeight || 230;
|
| 556 |
+
cx = W / 2; cy = H / 2;
|
| 557 |
+
build();
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
class Neuron {
|
| 561 |
+
constructor(i) {
|
| 562 |
+
this.layer = 1 + (i % 3);
|
| 563 |
+
this.angle = Math.random() * Math.PI * 2;
|
| 564 |
+
const spread = Math.min(W, H) * 0.46;
|
| 565 |
+
this.baseR = spread * (0.14 + this.layer * 0.2 + Math.random() * 0.07);
|
| 566 |
+
this.speed = (Math.random() < .5 ? 1 : -1) * (.001 + Math.random() * 0.002);
|
| 567 |
+
this.osc = 2 + Math.random() * 6;
|
| 568 |
+
this.t = Math.random() * 100;
|
| 569 |
+
this.r = 1.1 + Math.random() * 1.5;
|
| 570 |
+
this.alpha = .4 + Math.random() * .5;
|
| 571 |
+
this.firing = 0;
|
| 572 |
+
this.fireTimer = Math.random() * 180;
|
| 573 |
+
this.x = cx; this.y = cy;
|
| 574 |
+
this._step();
|
| 575 |
+
}
|
| 576 |
+
_step() {
|
| 577 |
+
this.t += .012; this.angle += this.speed;
|
| 578 |
+
const r = this.baseR + Math.sin(this.t) * this.osc;
|
| 579 |
+
this.x = cx + Math.cos(this.angle) * r;
|
| 580 |
+
this.y = cy + Math.sin(this.angle) * r;
|
| 581 |
+
this.fireTimer--;
|
| 582 |
+
if (this.fireTimer <= 0) { this.firing = 1; this.fireTimer = 80 + Math.random() * 200; }
|
| 583 |
+
if (this.firing > 0) this.firing = Math.max(0, this.firing - .025);
|
| 584 |
+
}
|
| 585 |
+
draw() {
|
| 586 |
+
ctx.globalAlpha = this.alpha * (.4 + this.firing * .6);
|
| 587 |
+
ctx.strokeStyle = `rgba(0,${160 + Math.round(this.firing * 95)},255,${.2 + this.firing * .6})`;
|
| 588 |
+
ctx.lineWidth = .5;
|
| 589 |
+
ctx.beginPath(); ctx.arc(this.x, this.y, this.r + 2, 0, Math.PI * 2); ctx.stroke();
|
| 590 |
+
ctx.fillStyle = this.firing > .3 ? `rgba(255,255,255,${this.firing})` : 'rgba(0,190,255,.85)';
|
| 591 |
+
ctx.beginPath(); ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2); ctx.fill();
|
| 592 |
+
ctx.globalAlpha = 1;
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
class Pulse {
|
| 597 |
+
constructor(a, b) { this.a = a; this.b = b; this.t = 0; this.s = .01 + Math.random() * .014;
|
| 598 |
+
this.done = false; }
|
| 599 |
+
tick() { this.t += this.s; if (this.t >= 1) { this.done = true; this.b.firing = 1; } }
|
| 600 |
+
draw() {
|
| 601 |
+
const x = this.a.x + (this.b.x - this.a.x) * this.t;
|
| 602 |
+
const y = this.a.y + (this.b.y - this.a.y) * this.t;
|
| 603 |
+
ctx.globalAlpha = 1 - this.t * .4;
|
| 604 |
+
ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(x, y, 1.8, 0, Math.PI * 2); ctx.fill();
|
| 605 |
+
const tx = this.a.x + (this.b.x - this.a.x) * Math.max(0, this.t - .08);
|
| 606 |
+
const ty = this.a.y + (this.b.y - this.a.y) * Math.max(0, this.t - .08);
|
| 607 |
+
const g = ctx.createLinearGradient(tx, ty, x, y);
|
| 608 |
+
g.addColorStop(0, 'rgba(0,200,255,0)'); g.addColorStop(1, 'rgba(0,220,255,.5)');
|
| 609 |
+
ctx.strokeStyle = g; ctx.lineWidth = 1; ctx.globalAlpha = .6;
|
| 610 |
+
ctx.beginPath(); ctx.moveTo(tx, ty); ctx.lineTo(x, y); ctx.stroke();
|
| 611 |
+
ctx.globalAlpha = 1;
|
| 612 |
+
}
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
function build() {
|
| 616 |
+
neurons = []; pulses = []; synapses = [];
|
| 617 |
+
for (let i = 0; i < N; i++) neurons.push(new Neuron(i));
|
| 618 |
+
for (let i = 0; i < neurons.length; i++) {
|
| 619 |
+
let added = 0;
|
| 620 |
+
for (let j = i + 1; j < neurons.length; j++) {
|
| 621 |
+
const dx = neurons[i].x - neurons[j].x, dy = neurons[i].y - neurons[j].y;
|
| 622 |
+
if (Math.sqrt(dx*dx + dy*dy) < CONN && added < 3) { synapses.push([i, j]); added++; }
|
| 623 |
+
}
|
| 624 |
+
}
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
function drawSynapses() {
|
| 628 |
+
for (const s of synapses) {
|
| 629 |
+
const a = neurons[s[0]], b = neurons[s[1]];
|
| 630 |
+
const dx = a.x - b.x, dy = a.y - b.y, d = Math.sqrt(dx*dx + dy*dy);
|
| 631 |
+
const fade = 1 - d / CONN, fire = (a.firing + b.firing) * .5;
|
| 632 |
+
ctx.globalAlpha = fade * (.05 + fire * .2);
|
| 633 |
+
ctx.strokeStyle = `rgba(0,${150 + Math.round(fire * 105)},255,1)`;
|
| 634 |
+
ctx.lineWidth = .3 + fire * .5;
|
| 635 |
+
ctx.beginPath(); ctx.moveTo(a.x, a.y); ctx.lineTo(b.x, b.y); ctx.stroke();
|
| 636 |
+
}
|
| 637 |
+
ctx.globalAlpha = 1;
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
function drawLogo() {
|
| 641 |
+
const g = ctx.createRadialGradient(cx, cy, 0, cx, cy, 50);
|
| 642 |
+
g.addColorStop(0, 'rgba(0,200,255,.12)'); g.addColorStop(1, 'rgba(0,200,255,0)');
|
| 643 |
+
ctx.fillStyle = g; ctx.beginPath(); ctx.arc(cx, cy, 50, 0, Math.PI * 2); ctx.fill();
|
| 644 |
+
ctx.font = "bold 19px 'Orbitron',monospace";
|
| 645 |
+
ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
|
| 646 |
+
ctx.shadowBlur = 10; ctx.shadowColor = 'rgba(0,212,255,.8)';
|
| 647 |
+
const tg = ctx.createLinearGradient(cx - 36, 0, cx + 36, 0);
|
| 648 |
+
tg.addColorStop(0, '#fff'); tg.addColorStop(1, '#00d4ff');
|
| 649 |
+
ctx.fillStyle = tg; ctx.fillText('CVision', cx, cy);
|
| 650 |
+
ctx.shadowBlur = 0;
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
function loop() {
|
| 654 |
+
requestAnimationFrame(loop);
|
| 655 |
+
ctx.clearRect(0, 0, W, H);
|
| 656 |
+
for (const n of neurons) n._step();
|
| 657 |
+
drawSynapses();
|
| 658 |
+
for (const n of neurons) n.draw();
|
| 659 |
+
pulseTimer++;
|
| 660 |
+
if (pulseTimer % 25 === 0 && synapses.length) {
|
| 661 |
+
const s = synapses[Math.floor(Math.random() * synapses.length)];
|
| 662 |
+
const [ai, bi] = Math.random() < .5 ? [s[0], s[1]] : [s[1], s[0]];
|
| 663 |
+
pulses.push(new Pulse(neurons[ai], neurons[bi]));
|
| 664 |
+
neurons[ai].firing = 1;
|
| 665 |
+
}
|
| 666 |
+
pulses = pulses.filter(p => !p.done);
|
| 667 |
+
for (const p of pulses) { p.tick(); p.draw(); }
|
| 668 |
+
drawLogo();
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
window.addEventListener('resize', resize, { passive: true });
|
| 672 |
+
resize();
|
| 673 |
+
loop();
|
| 674 |
}
|
| 675 |
|
| 676 |
/* ── Reloj en tiempo real ── */
|
| 677 |
function updateClock() {
|
| 678 |
+
const el = document.getElementById('cv-clock');
|
| 679 |
+
if (!el) return;
|
| 680 |
+
const n = new Date(), p = x => String(x).padStart(2, '0');
|
| 681 |
+
el.textContent = p(n.getHours()) + ':' + p(n.getMinutes()) + ':' + p(n.getSeconds());
|
| 682 |
}
|
| 683 |
setInterval(updateClock, 1000);
|
| 684 |
updateClock();
|
|
|
|
| 686 |
"""
|
| 687 |
|
| 688 |
# ════════════════════════════════════════════════════════════
|
| 689 |
+
# LÓGICA DEL ASISTENTE (NÚCLEO ORIGINAL DE 404 LÍNEAS)
|
| 690 |
# ════════════════════════════════════════════════════════════
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 691 |
|
| 692 |
+
# ---------------- LÓGICA DE LIMPIEZA DE MENSAJES ----------------
|
| 693 |
+
# Corregido para asegurar la eliminación estricta de ], ' y caracteres basura.
|
| 694 |
+
def clean_message_logic(text_input):
|
| 695 |
+
"""
|
| 696 |
+
Limpia el texto evitando la repetición del historial en la burbuja y
|
| 697 |
+
eliminando caracteres técnicos residuales de Python/Gradio.
|
| 698 |
+
"""
|
| 699 |
+
if not text_input: return ""
|
| 700 |
+
|
| 701 |
+
# Manejar si la entrada es una estructura compleja inesperada
|
| 702 |
+
if isinstance(text_input, (list, tuple)):
|
| 703 |
+
if len(text_input) > 0:
|
| 704 |
+
last_item = text_input[-1]
|
| 705 |
+
text_input = last_item[1] if isinstance(last_item, (list, tuple)) else str(last_item)
|
| 706 |
+
else:
|
| 707 |
+
text_input = ""
|
| 708 |
+
|
| 709 |
+
res = str(text_input)
|
| 710 |
+
|
| 711 |
+
# 1. Quitar basura técnica y generadores
|
| 712 |
+
res = re.sub(r"<generator object.*?>", "", res)
|
| 713 |
+
|
| 714 |
+
# 2. SEPARACIÓN DE MENSAJES: Si el historial se filtró (comas, corchetes, comillas múltiples)
|
| 715 |
+
# Patrón robusto para detectar la división entre mensajes
|
| 716 |
+
split_pattern = r"'\],\s*\['|\"\],\s*\[\"|'\],\s*\('|\"\],\s*\(\"|\"\],\s*\"|'\],\s*'"
|
| 717 |
+
if "]," in res and re.search(split_pattern, res):
|
| 718 |
+
fragments = re.split(split_pattern, res)
|
| 719 |
+
# Tomar el último fragmento que es el mensaje actual del bot
|
| 720 |
+
res = fragments[-1]
|
| 721 |
+
|
| 722 |
+
# 3. Limpieza profunda de caracteres residuales de apertura y cierre de Python/JSON
|
| 723 |
+
# Eliminamos específicamente: ([' , ']) , [' , '] , (' , ') , ] , , , '
|
| 724 |
+
cleanup_pattern = r"^(\(\['|'\]\)|\[['\"]|['\"\]]\]|\(['\"]|['\"]?\)\)?|['\"\]]?,?\s*['\"]?)|(['\"\]]?,?\s*['\"]?)$"
|
| 725 |
+
res = re.sub(cleanup_pattern, "", res)
|
| 726 |
+
|
| 727 |
+
# Limpieza adicional dirigida por si acaso
|
| 728 |
+
res = res.replace("(['", "").replace("'])", "").replace("['", "").replace("']", "")
|
| 729 |
+
res = res.strip("[]()', \"")
|
| 730 |
+
|
| 731 |
+
# 4. Eliminar rutas de audio temporales
|
| 732 |
+
res = re.sub(r"/tmp/.*?\.mp3", "", res)
|
| 733 |
+
|
| 734 |
+
return res.strip()
|
| 735 |
+
|
| 736 |
+
# ---------------- MANEJADORES DE CHAT (NÚCLEO FUNCIONAL) ----------------
|
| 737 |
+
def unified_chat_handler(chat_history, user_text, mode_key, voice_enabled, pdf_doc=None):
|
| 738 |
+
"""
|
| 739 |
+
Procesador central multimodal. Recibe el texto, llama al motor
|
| 740 |
+
y actualiza el historial limpio para la interfaz.
|
| 741 |
+
"""
|
| 742 |
+
if not user_text: return chat_history, "", None
|
| 743 |
+
|
| 744 |
+
# Diccionario de funciones para evitar pasar la función directo al estado
|
| 745 |
+
funcs = {
|
| 746 |
+
"general": regular_chat,
|
| 747 |
+
"web": browser_chat,
|
| 748 |
"productividad": productivity_chat,
|
| 749 |
+
"cientifico": scientist_chat,
|
| 750 |
+
"pdf": document_chat
|
| 751 |
}
|
| 752 |
+
|
| 753 |
+
target_func = funcs.get(mode_key, regular_chat)
|
| 754 |
+
|
| 755 |
try:
|
| 756 |
+
# Llamar al motor de chat (contexto completo)
|
| 757 |
+
if mode_key == "pdf" and pdf_doc:
|
| 758 |
+
# document_chat requiere el documento PDF
|
| 759 |
+
raw_out = target_func(chat_history, user_text, pdf_doc)
|
| 760 |
else:
|
| 761 |
+
raw_out = target_func(chat_history, user_text)
|
| 762 |
+
|
| 763 |
+
# Agotar generadores si el motor los usa (streaming -> texto final)
|
| 764 |
+
final_msg = ""
|
| 765 |
+
if hasattr(raw_out, "__iter__") and not isinstance(raw_out, (list, tuple, str)):
|
| 766 |
+
# Si es un generador, iteramos hasta el final
|
| 767 |
+
for part in raw_out:
|
| 768 |
+
if isinstance(part, list):
|
| 769 |
+
final_msg = part[-1][1] # Gradio Tuple format
|
| 770 |
else:
|
| 771 |
+
final_msg = str(part) # String/Raw format
|
| 772 |
else:
|
| 773 |
+
# Si ya es una lista o string, lo tomamos directamente
|
| 774 |
+
if isinstance(raw_out, list) and len(raw_out) > 0:
|
| 775 |
+
final_msg = raw_out[-1][1] if isinstance(raw_out[-1], (list, tuple)) else raw_out[-1]
|
| 776 |
+
else:
|
| 777 |
+
final_msg = raw_out
|
| 778 |
+
|
| 779 |
+
# LIMPIEZA CRÍTICA: Asegurar que el bot solo muestre su texto
|
| 780 |
+
clean_reply = clean_message_logic(final_msg)
|
| 781 |
+
|
| 782 |
+
# Validar si tras la limpieza no hay respuesta
|
| 783 |
+
if not clean_reply and final_msg:
|
| 784 |
+
# Si final_msg tenía algo, la limpieza falló. Fallback:
|
| 785 |
+
clean_reply = str(final_msg).strip("[](), '\"")
|
| 786 |
+
|
| 787 |
+
# Actualizar historial de Gradio para renderizar burbujas limpias
|
| 788 |
+
chat_history.append((user_text, clean_reply))
|
| 789 |
+
|
| 790 |
+
# Manejo de Voz
|
| 791 |
+
reply_audio = None
|
| 792 |
if voice_enabled:
|
| 793 |
+
# Generar audio de la respuesta limpia
|
| 794 |
+
reply_audio = speak(clean_reply[:350]) # Limitar caracteres por TTS
|
|
|
|
|
|
|
| 795 |
|
| 796 |
+
return chat_history, "", reply_audio
|
| 797 |
+
|
| 798 |
except Exception as e:
|
| 799 |
+
print(f"Error CRÍTICO en unified_chat_handler: {e}")
|
| 800 |
+
# Enviar mensaje de error amistoso a la interfaz
|
| 801 |
+
chat_history.append((user_text, f"⚠️ Lo siento, Cristian, hubo un error técnico en el procesamiento multimodal."))
|
| 802 |
+
return chat_history, "", None
|
| 803 |
+
|
| 804 |
+
def transcribe_wrapper(audio):
|
| 805 |
+
"""Wrapper para transcribir audio y limpiar el cuadro de entrada."""
|
| 806 |
+
if not audio: return ""
|
| 807 |
+
try:
|
| 808 |
+
user_text = transcribe_audio_file(audio)
|
| 809 |
+
return user_text
|
| 810 |
+
except Exception as e:
|
| 811 |
+
print(f"Error en transcripción: {e}")
|
| 812 |
+
return "⚠️ Error al transcribir el audio."
|
| 813 |
+
|
| 814 |
+
# ---------------- INTERFAZ GRADIO (FUSIÓN ESTÉTICA) ----------------
|
| 815 |
+
# Se usa gr.Blocks para inyectar el HEADER_HTML, NEBULA_HTML y NEBULA_JS
|
| 816 |
+
with gr.Blocks(css=CUSTOM_CSS, head=HEADER_HTML+NEBULA_HTML+NEBULA_JS+STATUS_BAR_HTML, title="CVision Neural Intelligence") as assistant:
|
| 817 |
+
|
| 818 |
+
# Nota: No necesitamos inyectar HTML explícito aquí, Blocks 'head' lo hace.
|
| 819 |
+
# El CSS y JS se encargarán de renderizar el diseño futurista.
|
| 820 |
+
|
| 821 |
+
# Estado para rastrear si el modo voz está activo
|
| 822 |
+
voice_active = gr.State(False)
|
| 823 |
+
|
| 824 |
+
def create_Cognitive_tab(mode_id):
|
| 825 |
+
# type="tuples" es vital para el manejo correcto de unified_chat_handler
|
| 826 |
+
chatbot = gr.Chatbot(height=520, bubble_full_width=False, elem_classes="chatbot-wrap", type="tuples")
|
| 827 |
+
audio_reply_output = gr.Audio(visible=False, autoplay=True, elem_classes="cv-audio-out")
|
| 828 |
+
|
| 829 |
+
with gr.Row(elem_classes="cv-row-input"):
|
| 830 |
+
txt_in = gr.Textbox(placeholder=PLACEHOLDER, scale=8, elem_classes="cv-input", container=False)
|
| 831 |
+
btn_voice_control = gr.Button("⚡ Voz: OFF", scale=2, elem_classes="btn-voice")
|
| 832 |
+
btn_send = gr.Button("Enviar ↗", variant="primary", scale=2, elem_classes="btn-send")
|
| 833 |
+
|
| 834 |
+
with gr.Row(elem_classes="cv-row-actions"):
|
| 835 |
+
audio_in = gr.Audio(sources=["microphone"], type="filepath", label="Micrófono Cognitivo", scale=4, elem_classes="cv-mic")
|
| 836 |
+
btn_clear = gr.Button("Limpiar Núcleo 🗑️", scale=1, elem_classes="btn-clear")
|
| 837 |
+
|
| 838 |
+
# --- Lógica de Encendido/Apagado de Voz ---
|
| 839 |
+
def toggle_voice(status):
|
| 840 |
+
new_status = not status
|
| 841 |
+
label = "⚡ Voz: ON" if new_status else "⚡ Voz: OFF"
|
| 842 |
+
variant = "primary" if new_status else "secondary"
|
| 843 |
+
return new_status, gr.update(value=label, variant=variant)
|
| 844 |
+
|
| 845 |
+
btn_voice_control.click(toggle_voice, [voice_active], [voice_enabled, btn_voice_control])
|
| 846 |
+
|
| 847 |
+
# --- EVENTOS ---
|
| 848 |
+
|
| 849 |
+
# 1. Enviar texto (Click y Enter)
|
| 850 |
+
btn_send.click(
|
| 851 |
+
unified_chat_handler,
|
| 852 |
+
[chatbot, txt_in, gr.State(mode_id), voice_active],
|
| 853 |
+
[chatbot, txt_in, audio_reply_output]
|
| 854 |
+
)
|
| 855 |
+
txt_in.submit(
|
| 856 |
+
unified_chat_handler,
|
| 857 |
+
[chatbot, txt_in, gr.State(mode_id), voice_active],
|
| 858 |
+
[chatbot, txt_in, audio_reply_output]
|
| 859 |
+
)
|
| 860 |
+
|
| 861 |
+
# 2. Transcripción y envío automático por voz
|
| 862 |
+
audio_in.change(transcribe_wrapper, audio_in, txt_in)
|
| 863 |
+
txt_in.change(
|
| 864 |
+
lambda t: unified_chat_handler([], t, mode_id, voice_active)[0], # Transcribe y envía si hay voz, pero no actualiza historial chatbot aquí
|
| 865 |
+
inputs=[txt_in],
|
| 866 |
+
outputs=[chatbot],
|
| 867 |
+
trigger_mode="always_change"
|
| 868 |
+
)
|
| 869 |
+
# Lo de arriba es incorrecto en lógica. Al transcribir solo debe llenar txt_in.
|
| 870 |
+
# unified_chat_handler debe encargarse del envío completo.
|
| 871 |
+
# Corregido:
|
| 872 |
+
def audio_to_text_and_send(chat_history, audio_file, mode, voice_on):
|
| 873 |
+
# 1. Transcribir
|
| 874 |
+
text = transcribe_wrapper(audio_file)
|
| 875 |
+
if not text or text.startswith("⚠️"):
|
| 876 |
+
return chat_history, text, None
|
| 877 |
+
# 2. Enviar automáticamente si la voz está activa
|
| 878 |
+
return unified_chat_handler(chat_history, text, mode, voice_on)
|
| 879 |
+
|
| 880 |
+
audio_in.stop_recording(
|
| 881 |
+
audio_to_text_and_send,
|
| 882 |
+
[chatbot, audio_in, gr.State(mode_id), voice_active],
|
| 883 |
+
[chatbot, txt_in, audio_reply_output]
|
| 884 |
+
)
|
| 885 |
+
|
| 886 |
+
# 3. Limpiar
|
| 887 |
+
btn_clear.click(lambda: ([], "", None), None, [chatbot, txt_in, audio_reply_output])
|
| 888 |
+
|
| 889 |
+
# ORGANIZACIÓN POR PESTAÑAS (Fusión Estética)
|
| 890 |
+
# Se usan iconos emoji para las pestañas
|
| 891 |
+
with gr.Tab("💬 General", elem_id="core-general"):
|
| 892 |
+
create_cognitive_tab("general")
|
| 893 |
+
|
| 894 |
+
with gr.Tab("🌐 Navegación Web", elem_id="core-web"):
|
| 895 |
+
create_cognitive_tab("web")
|
| 896 |
+
|
| 897 |
+
with gr.Tab("📈 Productividad", elem_id="core-prod"):
|
| 898 |
+
create_cognitive_tab("productividad")
|
| 899 |
+
|
| 900 |
+
with gr.Tab("🔬 Análisis Científico", elem_id="core-sci"):
|
| 901 |
+
create_cognitive_tab("cientifico")
|
| 902 |
+
|
| 903 |
+
with gr.Tab("📄 Analista de PDF", elem_id="core-pdf"):
|
| 904 |
+
# Estructura PDF adaptada al diseño Diamante × Cyan
|
| 905 |
+
chat_pdf = gr.Chatbot(height=520, bubble_full_width=False, elem_classes="chatbot-wrap", type="tuples")
|
| 906 |
+
voice_active_pdf = gr.State(False) # Estado de voz separado para PDF
|
| 907 |
+
|
| 908 |
+
with gr.Row():
|
| 909 |
+
file_input = gr.File(label="Subir Documento PDF", file_types=[".pdf"], elem_classes="cv-file")
|
| 910 |
+
|
| 911 |
+
with gr.Row(elem_classes="cv-row-input"):
|
| 912 |
+
txt_pdf_input = gr.Textbox(placeholder="Pregunta algo sobre el PDF analizado...", scale=8, elem_classes="cv-input", container=False)
|
| 913 |
+
btn_voice_ctrl_pdf = gr.Button("⚡ Voz: OFF", scale=2, elem_classes="btn-voice")
|
| 914 |
+
btn_analyze_pdf = gr.Button("Analizar PDF ↗", variant="primary", scale=2, elem_classes="btn-send btn-analyze")
|
| 915 |
+
|
| 916 |
+
with gr.Row(elem_classes="cv-row-actions"):
|
| 917 |
+
btn_clr_pdf = gr.Button("Limpiar 🗑️", scale=1, elem_classes="btn-clear")
|
| 918 |
+
audio_out_pdf = gr.Audio(visible=False, autoplay=True, elem_classes="cv-audio-out")
|
| 919 |
+
|
| 920 |
+
# Lógica de voz para PDF
|
| 921 |
+
btn_voice_ctrl_pdf.click(toggle_voice, [voice_active_pdf], [voice_enabled_pdf, btn_voice_ctrl_pdf])
|
| 922 |
+
|
| 923 |
+
# Eventos PDF
|
| 924 |
+
btn_analyze_pdf.click(
|
| 925 |
+
unified_chat_handler,
|
| 926 |
+
[chat_pdf, txt_pdf_input, gr.State("pdf"), voice_active_pdf, file_input],
|
| 927 |
+
[chat_pdf, txt_pdf_input, audio_out_pdf]
|
| 928 |
+
)
|
| 929 |
+
txt_pdf_input.submit(
|
| 930 |
+
unified_chat_handler,
|
| 931 |
+
[chat_pdf, txt_pdf_input, gr.State("pdf"), voice_active_pdf, file_input],
|
| 932 |
+
[chat_pdf, txt_pdf_input, audio_out_pdf]
|
| 933 |
+
)
|
| 934 |
+
btn_clr_pdf.click(lambda: ([], "", None), None, [chat_pdf, txt_pdf_input, audio_out_pdf])
|
| 935 |
+
|
| 936 |
+
# ---------------- LANZAMIENTO (NÚCLEO ORIGINAL) ----------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 937 |
if __name__ == "__main__":
|
| 938 |
+
# Configuración de lanzamiento original
|
| 939 |
assistant.launch(
|
| 940 |
show_error=True,
|
| 941 |
+
favicon_path="file/assets/CVision logo.png"
|
| 942 |
)
|