Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
|
|
|
| 3 |
|
| 4 |
# ---------------------------
|
| 5 |
# QUANTUM NEURAL INTERFACE
|
|
@@ -9,9 +10,7 @@ custom_css = """
|
|
| 9 |
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 10 |
/* CORE SYSTEM ARCHITECTURE */
|
| 11 |
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 12 |
-
|
| 13 |
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');
|
| 14 |
-
|
| 15 |
:root {
|
| 16 |
--primary-glow: #00fff7;
|
| 17 |
--secondary-glow: #7b2ff7;
|
|
@@ -19,12 +18,9 @@ custom_css = """
|
|
| 19 |
--neural-dark: #0a0e27;
|
| 20 |
--glass-bg: rgba(255, 255, 255, 0.03);
|
| 21 |
}
|
| 22 |
-
|
| 23 |
* {
|
| 24 |
font-family: 'Orbitron', monospace !important;
|
| 25 |
}
|
| 26 |
-
|
| 27 |
-
/* ANIMATED BACKGROUND SYSTEM */
|
| 28 |
body, .gradio-container {
|
| 29 |
margin: 0;
|
| 30 |
padding: 0;
|
|
@@ -33,7 +29,6 @@ body, .gradio-container {
|
|
| 33 |
position: relative;
|
| 34 |
overflow-x: hidden;
|
| 35 |
}
|
| 36 |
-
|
| 37 |
.gradio-container::before {
|
| 38 |
content: "";
|
| 39 |
position: fixed;
|
|
@@ -49,13 +44,10 @@ body, .gradio-container {
|
|
| 49 |
pointer-events: none;
|
| 50 |
z-index: 0;
|
| 51 |
}
|
| 52 |
-
|
| 53 |
@keyframes backgroundPulse {
|
| 54 |
0%, 100% { opacity: 1; transform: scale(1); }
|
| 55 |
50% { opacity: 0.8; transform: scale(1.1); }
|
| 56 |
}
|
| 57 |
-
|
| 58 |
-
/* PARTICLE SYSTEM */
|
| 59 |
.gradio-container::after {
|
| 60 |
content: "";
|
| 61 |
position: fixed;
|
|
@@ -74,16 +66,10 @@ body, .gradio-container {
|
|
| 74 |
pointer-events: none;
|
| 75 |
z-index: 0;
|
| 76 |
}
|
| 77 |
-
|
| 78 |
@keyframes particleFloat {
|
| 79 |
0% { background-position: 0% 0%; }
|
| 80 |
100% { background-position: 100% 100%; }
|
| 81 |
}
|
| 82 |
-
|
| 83 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 84 |
-
/* NEURAL HEADER SYSTEM */
|
| 85 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 86 |
-
|
| 87 |
#title {
|
| 88 |
position: relative;
|
| 89 |
font-size: 48px;
|
|
@@ -100,17 +86,14 @@ body, .gradio-container {
|
|
| 100 |
letter-spacing: 4px;
|
| 101 |
z-index: 10;
|
| 102 |
}
|
| 103 |
-
|
| 104 |
@keyframes gradientFlow {
|
| 105 |
0% { background-position: 0% 50%; }
|
| 106 |
100% { background-position: 300% 50%; }
|
| 107 |
}
|
| 108 |
-
|
| 109 |
@keyframes titlePulse {
|
| 110 |
0%, 100% { transform: scale(1); }
|
| 111 |
50% { transform: scale(1.02); }
|
| 112 |
}
|
| 113 |
-
|
| 114 |
#title::before {
|
| 115 |
content: "";
|
| 116 |
position: absolute;
|
|
@@ -122,16 +105,10 @@ body, .gradio-container {
|
|
| 122 |
background: linear-gradient(90deg, transparent, var(--primary-glow), transparent);
|
| 123 |
animation: scanLine 3s linear infinite;
|
| 124 |
}
|
| 125 |
-
|
| 126 |
@keyframes scanLine {
|
| 127 |
0%, 100% { opacity: 0; }
|
| 128 |
50% { opacity: 1; }
|
| 129 |
}
|
| 130 |
-
|
| 131 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 132 |
-
/* QUANTUM CHATBOT INTERFACE */
|
| 133 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 134 |
-
|
| 135 |
.chatbot {
|
| 136 |
border-radius: 20px !important;
|
| 137 |
background: var(--glass-bg) !important;
|
|
@@ -146,58 +123,10 @@ body, .gradio-container {
|
|
| 146 |
animation: chatbotIntro 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
|
| 147 |
z-index: 10;
|
| 148 |
}
|
| 149 |
-
|
| 150 |
@keyframes chatbotIntro {
|
| 151 |
0% { opacity: 0; transform: translateY(30px) scale(0.95); }
|
| 152 |
100% { opacity: 1; transform: translateY(0) scale(1); }
|
| 153 |
}
|
| 154 |
-
|
| 155 |
-
.chatbot::before {
|
| 156 |
-
content: "";
|
| 157 |
-
position: absolute;
|
| 158 |
-
top: -50%;
|
| 159 |
-
left: -50%;
|
| 160 |
-
width: 200%;
|
| 161 |
-
height: 200%;
|
| 162 |
-
background: linear-gradient(
|
| 163 |
-
45deg,
|
| 164 |
-
transparent,
|
| 165 |
-
rgba(0, 255, 247, 0.1),
|
| 166 |
-
transparent
|
| 167 |
-
);
|
| 168 |
-
animation: scan 8s linear infinite;
|
| 169 |
-
pointer-events: none;
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
@keyframes scan {
|
| 173 |
-
0% { transform: translate(-50%, -50%) rotate(0deg); }
|
| 174 |
-
100% { transform: translate(-50%, -50%) rotate(360deg); }
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 178 |
-
/* MESSAGE QUANTUM STATES */
|
| 179 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 180 |
-
|
| 181 |
-
.message {
|
| 182 |
-
position: relative;
|
| 183 |
-
margin: 12px 0;
|
| 184 |
-
animation: messageSpawn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
|
| 185 |
-
}
|
| 186 |
-
|
| 187 |
-
@keyframes messageSpawn {
|
| 188 |
-
0% {
|
| 189 |
-
opacity: 0;
|
| 190 |
-
transform: translateY(20px) scale(0.9);
|
| 191 |
-
filter: blur(10px);
|
| 192 |
-
}
|
| 193 |
-
100% {
|
| 194 |
-
opacity: 1;
|
| 195 |
-
transform: translateY(0) scale(1);
|
| 196 |
-
filter: blur(0);
|
| 197 |
-
}
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
/* USER NEURAL SIGNATURE */
|
| 201 |
.message.user, .user {
|
| 202 |
background: linear-gradient(135deg, rgba(0, 255, 247, 0.2), rgba(0, 200, 255, 0.1)) !important;
|
| 203 |
border-left: 3px solid var(--primary-glow) !important;
|
|
@@ -210,31 +139,6 @@ body, .gradio-container {
|
|
| 210 |
overflow: hidden;
|
| 211 |
transition: all 0.3s ease;
|
| 212 |
}
|
| 213 |
-
|
| 214 |
-
.message.user:hover, .user:hover {
|
| 215 |
-
transform: translateX(-5px);
|
| 216 |
-
box-shadow:
|
| 217 |
-
0 6px 25px rgba(0, 255, 247, 0.5),
|
| 218 |
-
inset 0 0 30px rgba(0, 255, 247, 0.2) !important;
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
.message.user::before, .user::before {
|
| 222 |
-
content: "";
|
| 223 |
-
position: absolute;
|
| 224 |
-
top: 0;
|
| 225 |
-
left: -100%;
|
| 226 |
-
width: 100%;
|
| 227 |
-
height: 100%;
|
| 228 |
-
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
|
| 229 |
-
animation: shimmer 3s infinite;
|
| 230 |
-
}
|
| 231 |
-
|
| 232 |
-
@keyframes shimmer {
|
| 233 |
-
0% { left: -100%; }
|
| 234 |
-
100% { left: 100%; }
|
| 235 |
-
}
|
| 236 |
-
|
| 237 |
-
/* BOT NEURAL RESPONSE */
|
| 238 |
.message.bot, .bot {
|
| 239 |
background: linear-gradient(135deg, rgba(123, 47, 247, 0.2), rgba(147, 51, 234, 0.1)) !important;
|
| 240 |
border-left: 3px solid var(--secondary-glow) !important;
|
|
@@ -242,40 +146,11 @@ body, .gradio-container {
|
|
| 242 |
padding: 15px !important;
|
| 243 |
box-shadow:
|
| 244 |
0 4px 15px rgba(123, 47, 247, 0.3),
|
| 245 |
-
inset 0 0 20px rgba(123, 47,
|
| 246 |
position: relative;
|
| 247 |
overflow: hidden;
|
| 248 |
transition: all 0.3s ease;
|
| 249 |
}
|
| 250 |
-
|
| 251 |
-
.message.bot:hover, .bot:hover {
|
| 252 |
-
transform: translateX(5px);
|
| 253 |
-
box-shadow:
|
| 254 |
-
0 6px 25px rgba(123, 47, 247, 0.5),
|
| 255 |
-
inset 0 0 30px rgba(123, 47, 247, 0.2) !important;
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
.message.bot::after, .bot::after {
|
| 259 |
-
content: "";
|
| 260 |
-
position: absolute;
|
| 261 |
-
bottom: 0;
|
| 262 |
-
right: 0;
|
| 263 |
-
width: 50px;
|
| 264 |
-
height: 50px;
|
| 265 |
-
background: radial-gradient(circle, var(--secondary-glow), transparent);
|
| 266 |
-
opacity: 0.3;
|
| 267 |
-
animation: pulse 2s ease-in-out infinite;
|
| 268 |
-
}
|
| 269 |
-
|
| 270 |
-
@keyframes pulse {
|
| 271 |
-
0%, 100% { transform: scale(1); opacity: 0.3; }
|
| 272 |
-
50% { transform: scale(1.5); opacity: 0.1; }
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 276 |
-
/* INPUT NEURAL INTERFACE */
|
| 277 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 278 |
-
|
| 279 |
textarea, input[type="text"] {
|
| 280 |
border-radius: 15px !important;
|
| 281 |
background: var(--glass-bg) !important;
|
|
@@ -289,7 +164,6 @@ textarea, input[type="text"] {
|
|
| 289 |
transition: all 0.3s ease;
|
| 290 |
font-size: 14px !important;
|
| 291 |
}
|
| 292 |
-
|
| 293 |
textarea:focus, input[type="text"]:focus {
|
| 294 |
outline: none !important;
|
| 295 |
border: 1px solid var(--primary-glow) !important;
|
|
@@ -298,182 +172,6 @@ textarea:focus, input[type="text"]:focus {
|
|
| 298 |
inset 0 0 30px rgba(0, 255, 247, 0.1) !important;
|
| 299 |
transform: scale(1.01);
|
| 300 |
}
|
| 301 |
-
|
| 302 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 303 |
-
/* CONTROL PANEL INTERFACE */
|
| 304 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 305 |
-
|
| 306 |
-
.gr-button {
|
| 307 |
-
background: linear-gradient(135deg, rgba(0, 255, 247, 0.2), rgba(123, 47, 247, 0.2)) !important;
|
| 308 |
-
border: 1px solid var(--primary-glow) !important;
|
| 309 |
-
border-radius: 10px !important;
|
| 310 |
-
color: white !important;
|
| 311 |
-
font-weight: 700 !important;
|
| 312 |
-
padding: 12px 24px !important;
|
| 313 |
-
box-shadow: 0 4px 15px rgba(0, 255, 247, 0.3) !important;
|
| 314 |
-
transition: all 0.3s ease !important;
|
| 315 |
-
position: relative;
|
| 316 |
-
overflow: hidden;
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
.gr-button:hover {
|
| 320 |
-
transform: translateY(-2px);
|
| 321 |
-
box-shadow: 0 6px 25px rgba(0, 255, 247, 0.5) !important;
|
| 322 |
-
border-color: var(--secondary-glow) !important;
|
| 323 |
-
}
|
| 324 |
-
|
| 325 |
-
.gr-button:active {
|
| 326 |
-
transform: translateY(0);
|
| 327 |
-
}
|
| 328 |
-
|
| 329 |
-
.gr-button::before {
|
| 330 |
-
content: "";
|
| 331 |
-
position: absolute;
|
| 332 |
-
top: 50%;
|
| 333 |
-
left: 50%;
|
| 334 |
-
width: 0;
|
| 335 |
-
height: 0;
|
| 336 |
-
border-radius: 50%;
|
| 337 |
-
background: rgba(255, 255, 255, 0.3);
|
| 338 |
-
transform: translate(-50%, -50%);
|
| 339 |
-
transition: width 0.6s, height 0.6s;
|
| 340 |
-
}
|
| 341 |
-
|
| 342 |
-
.gr-button:hover::before {
|
| 343 |
-
width: 300px;
|
| 344 |
-
height: 300px;
|
| 345 |
-
}
|
| 346 |
-
|
| 347 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 348 |
-
/* SLIDER QUANTUM CONTROLS */
|
| 349 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 350 |
-
|
| 351 |
-
.gr-slider {
|
| 352 |
-
position: relative;
|
| 353 |
-
}
|
| 354 |
-
|
| 355 |
-
.gr-slider input[type="range"] {
|
| 356 |
-
-webkit-appearance: none;
|
| 357 |
-
appearance: none;
|
| 358 |
-
background: var(--glass-bg);
|
| 359 |
-
border-radius: 10px;
|
| 360 |
-
height: 8px;
|
| 361 |
-
outline: none;
|
| 362 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
|
| 363 |
-
}
|
| 364 |
-
|
| 365 |
-
.gr-slider input[type="range"]::-webkit-slider-thumb {
|
| 366 |
-
-webkit-appearance: none;
|
| 367 |
-
appearance: none;
|
| 368 |
-
width: 20px;
|
| 369 |
-
height: 20px;
|
| 370 |
-
background: var(--primary-glow);
|
| 371 |
-
border-radius: 50%;
|
| 372 |
-
cursor: pointer;
|
| 373 |
-
box-shadow: 0 0 15px var(--primary-glow);
|
| 374 |
-
transition: all 0.3s ease;
|
| 375 |
-
}
|
| 376 |
-
|
| 377 |
-
.gr-slider input[type="range"]::-webkit-slider-thumb:hover {
|
| 378 |
-
transform: scale(1.3);
|
| 379 |
-
box-shadow: 0 0 25px var(--primary-glow);
|
| 380 |
-
}
|
| 381 |
-
|
| 382 |
-
label {
|
| 383 |
-
color: var(--primary-glow) !important;
|
| 384 |
-
font-weight: 700 !important;
|
| 385 |
-
text-transform: uppercase;
|
| 386 |
-
letter-spacing: 1px;
|
| 387 |
-
font-size: 12px !important;
|
| 388 |
-
text-shadow: 0 0 10px rgba(0, 255, 247, 0.5);
|
| 389 |
-
}
|
| 390 |
-
|
| 391 |
-
/* οΏ½οΏ½οΏ½ββββββββββββββββββββββββββββββββββββββββββ */
|
| 392 |
-
/* SIDEBAR NEURAL PANEL */
|
| 393 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 394 |
-
|
| 395 |
-
.gr-sidebar {
|
| 396 |
-
background: var(--glass-bg) !important;
|
| 397 |
-
backdrop-filter: blur(20px) !important;
|
| 398 |
-
border-right: 1px solid rgba(0, 255, 247, 0.2) !important;
|
| 399 |
-
box-shadow: 0 0 40px rgba(0, 0, 0, 0.5) !important;
|
| 400 |
-
}
|
| 401 |
-
|
| 402 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 403 |
-
/* LOADING QUANTUM STATE */
|
| 404 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 405 |
-
|
| 406 |
-
.loading {
|
| 407 |
-
position: relative;
|
| 408 |
-
}
|
| 409 |
-
|
| 410 |
-
.loading::after {
|
| 411 |
-
content: "";
|
| 412 |
-
position: absolute;
|
| 413 |
-
width: 20px;
|
| 414 |
-
height: 20px;
|
| 415 |
-
border: 3px solid transparent;
|
| 416 |
-
border-top-color: var(--primary-glow);
|
| 417 |
-
border-radius: 50%;
|
| 418 |
-
animation: spin 1s linear infinite;
|
| 419 |
-
}
|
| 420 |
-
|
| 421 |
-
@keyframes spin {
|
| 422 |
-
0% { transform: rotate(0deg); }
|
| 423 |
-
100% { transform: rotate(360deg); }
|
| 424 |
-
}
|
| 425 |
-
|
| 426 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 427 |
-
/* SCROLLBAR CUSTOMIZATION */
|
| 428 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 429 |
-
|
| 430 |
-
::-webkit-scrollbar {
|
| 431 |
-
width: 10px;
|
| 432 |
-
}
|
| 433 |
-
|
| 434 |
-
::-webkit-scrollbar-track {
|
| 435 |
-
background: var(--neural-dark);
|
| 436 |
-
border-radius: 10px;
|
| 437 |
-
}
|
| 438 |
-
|
| 439 |
-
::-webkit-scrollbar-thumb {
|
| 440 |
-
background: linear-gradient(180deg, var(--primary-glow), var(--secondary-glow));
|
| 441 |
-
border-radius: 10px;
|
| 442 |
-
box-shadow: 0 0 10px var(--primary-glow);
|
| 443 |
-
}
|
| 444 |
-
|
| 445 |
-
::-webkit-scrollbar-thumb:hover {
|
| 446 |
-
background: linear-gradient(180deg, var(--secondary-glow), var(--danger-glow));
|
| 447 |
-
}
|
| 448 |
-
|
| 449 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 450 |
-
/* RESPONSIVE MATRIX GRID */
|
| 451 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 452 |
-
|
| 453 |
-
@media (max-width: 768px) {
|
| 454 |
-
#title {
|
| 455 |
-
font-size: 32px;
|
| 456 |
-
}
|
| 457 |
-
}
|
| 458 |
-
|
| 459 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 460 |
-
/* SYSTEM STATUS INDICATORS */
|
| 461 |
-
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 462 |
-
|
| 463 |
-
.status-indicator {
|
| 464 |
-
display: inline-block;
|
| 465 |
-
width: 10px;
|
| 466 |
-
height: 10px;
|
| 467 |
-
border-radius: 50%;
|
| 468 |
-
background: var(--primary-glow);
|
| 469 |
-
box-shadow: 0 0 10px var(--primary-glow);
|
| 470 |
-
animation: blink 2s ease-in-out infinite;
|
| 471 |
-
}
|
| 472 |
-
|
| 473 |
-
@keyframes blink {
|
| 474 |
-
0%, 100% { opacity: 1; }
|
| 475 |
-
50% { opacity: 0.3; }
|
| 476 |
-
}
|
| 477 |
"""
|
| 478 |
|
| 479 |
# ---------------------------
|
|
@@ -482,12 +180,12 @@ label {
|
|
| 482 |
|
| 483 |
def respond(
|
| 484 |
message,
|
| 485 |
-
history:
|
| 486 |
system_message,
|
| 487 |
max_tokens,
|
| 488 |
temperature,
|
| 489 |
top_p,
|
| 490 |
-
hf_token
|
| 491 |
):
|
| 492 |
system_message = (
|
| 493 |
"You are a highly advanced AI system. "
|
|
@@ -513,23 +211,22 @@ def respond(
|
|
| 513 |
temperature=temperature,
|
| 514 |
top_p=top_p,
|
| 515 |
):
|
| 516 |
-
choices = msg
|
| 517 |
token = ""
|
| 518 |
|
| 519 |
-
if len(choices) and choices[0].delta
|
| 520 |
token = choices[0].delta.content
|
| 521 |
|
| 522 |
response += token
|
| 523 |
yield response
|
| 524 |
|
| 525 |
-
|
| 526 |
# ---------------------------
|
| 527 |
# INTERFACE INITIALIZATION
|
| 528 |
# ---------------------------
|
| 529 |
|
| 530 |
with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
| 531 |
gr.HTML("<div id='title'>NEURAL QUANTUM INTERFACE</div>")
|
| 532 |
-
|
| 533 |
with gr.Row():
|
| 534 |
with gr.Column(scale=4):
|
| 535 |
chatbot = gr.Chatbot(
|
|
@@ -538,7 +235,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
|
| 538 |
height=600,
|
| 539 |
elem_classes=["chatbot"]
|
| 540 |
)
|
| 541 |
-
|
| 542 |
with gr.Row():
|
| 543 |
msg = gr.Textbox(
|
| 544 |
label="INPUT STREAM",
|
|
@@ -546,12 +243,12 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
|
| 546 |
scale=4
|
| 547 |
)
|
| 548 |
submit = gr.Button("TRANSMIT", scale=1)
|
| 549 |
-
|
| 550 |
with gr.Column(scale=1):
|
| 551 |
gr.LoginButton()
|
| 552 |
gr.Markdown("### SYSTEM PARAMETERS")
|
| 553 |
-
|
| 554 |
-
|
| 555 |
value="Advanced AI System",
|
| 556 |
label="CORE DIRECTIVE"
|
| 557 |
)
|
|
@@ -576,21 +273,21 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
|
| 576 |
step=0.05,
|
| 577 |
label="PROBABILITY THRESHOLD"
|
| 578 |
)
|
| 579 |
-
|
| 580 |
clear = gr.Button("RESET SYSTEM")
|
| 581 |
-
|
| 582 |
# Event handlers
|
| 583 |
msg.submit(
|
| 584 |
respond,
|
| 585 |
-
[msg, chatbot,
|
| 586 |
[chatbot]
|
| 587 |
)
|
| 588 |
submit.click(
|
| 589 |
respond,
|
| 590 |
-
[msg, chatbot,
|
| 591 |
[chatbot]
|
| 592 |
)
|
| 593 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 594 |
|
| 595 |
if __name__ == "__main__":
|
| 596 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
+
from typing import List, Dict
|
| 4 |
|
| 5 |
# ---------------------------
|
| 6 |
# QUANTUM NEURAL INTERFACE
|
|
|
|
| 10 |
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
| 11 |
/* CORE SYSTEM ARCHITECTURE */
|
| 12 |
/* βββββββββββββββββββββββββββββββββββββββββββ */
|
|
|
|
| 13 |
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');
|
|
|
|
| 14 |
:root {
|
| 15 |
--primary-glow: #00fff7;
|
| 16 |
--secondary-glow: #7b2ff7;
|
|
|
|
| 18 |
--neural-dark: #0a0e27;
|
| 19 |
--glass-bg: rgba(255, 255, 255, 0.03);
|
| 20 |
}
|
|
|
|
| 21 |
* {
|
| 22 |
font-family: 'Orbitron', monospace !important;
|
| 23 |
}
|
|
|
|
|
|
|
| 24 |
body, .gradio-container {
|
| 25 |
margin: 0;
|
| 26 |
padding: 0;
|
|
|
|
| 29 |
position: relative;
|
| 30 |
overflow-x: hidden;
|
| 31 |
}
|
|
|
|
| 32 |
.gradio-container::before {
|
| 33 |
content: "";
|
| 34 |
position: fixed;
|
|
|
|
| 44 |
pointer-events: none;
|
| 45 |
z-index: 0;
|
| 46 |
}
|
|
|
|
| 47 |
@keyframes backgroundPulse {
|
| 48 |
0%, 100% { opacity: 1; transform: scale(1); }
|
| 49 |
50% { opacity: 0.8; transform: scale(1.1); }
|
| 50 |
}
|
|
|
|
|
|
|
| 51 |
.gradio-container::after {
|
| 52 |
content: "";
|
| 53 |
position: fixed;
|
|
|
|
| 66 |
pointer-events: none;
|
| 67 |
z-index: 0;
|
| 68 |
}
|
|
|
|
| 69 |
@keyframes particleFloat {
|
| 70 |
0% { background-position: 0% 0%; }
|
| 71 |
100% { background-position: 100% 100%; }
|
| 72 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
#title {
|
| 74 |
position: relative;
|
| 75 |
font-size: 48px;
|
|
|
|
| 86 |
letter-spacing: 4px;
|
| 87 |
z-index: 10;
|
| 88 |
}
|
|
|
|
| 89 |
@keyframes gradientFlow {
|
| 90 |
0% { background-position: 0% 50%; }
|
| 91 |
100% { background-position: 300% 50%; }
|
| 92 |
}
|
|
|
|
| 93 |
@keyframes titlePulse {
|
| 94 |
0%, 100% { transform: scale(1); }
|
| 95 |
50% { transform: scale(1.02); }
|
| 96 |
}
|
|
|
|
| 97 |
#title::before {
|
| 98 |
content: "";
|
| 99 |
position: absolute;
|
|
|
|
| 105 |
background: linear-gradient(90deg, transparent, var(--primary-glow), transparent);
|
| 106 |
animation: scanLine 3s linear infinite;
|
| 107 |
}
|
|
|
|
| 108 |
@keyframes scanLine {
|
| 109 |
0%, 100% { opacity: 0; }
|
| 110 |
50% { opacity: 1; }
|
| 111 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
.chatbot {
|
| 113 |
border-radius: 20px !important;
|
| 114 |
background: var(--glass-bg) !important;
|
|
|
|
| 123 |
animation: chatbotIntro 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
|
| 124 |
z-index: 10;
|
| 125 |
}
|
|
|
|
| 126 |
@keyframes chatbotIntro {
|
| 127 |
0% { opacity: 0; transform: translateY(30px) scale(0.95); }
|
| 128 |
100% { opacity: 1; transform: translateY(0) scale(1); }
|
| 129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
.message.user, .user {
|
| 131 |
background: linear-gradient(135deg, rgba(0, 255, 247, 0.2), rgba(0, 200, 255, 0.1)) !important;
|
| 132 |
border-left: 3px solid var(--primary-glow) !important;
|
|
|
|
| 139 |
overflow: hidden;
|
| 140 |
transition: all 0.3s ease;
|
| 141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
.message.bot, .bot {
|
| 143 |
background: linear-gradient(135deg, rgba(123, 47, 247, 0.2), rgba(147, 51, 234, 0.1)) !important;
|
| 144 |
border-left: 3px solid var(--secondary-glow) !important;
|
|
|
|
| 146 |
padding: 15px !important;
|
| 147 |
box-shadow:
|
| 148 |
0 4px 15px rgba(123, 47, 247, 0.3),
|
| 149 |
+
inset 0 0 20px rgba(123, 47, 234, 0.1) !important;
|
| 150 |
position: relative;
|
| 151 |
overflow: hidden;
|
| 152 |
transition: all 0.3s ease;
|
| 153 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
textarea, input[type="text"] {
|
| 155 |
border-radius: 15px !important;
|
| 156 |
background: var(--glass-bg) !important;
|
|
|
|
| 164 |
transition: all 0.3s ease;
|
| 165 |
font-size: 14px !important;
|
| 166 |
}
|
|
|
|
| 167 |
textarea:focus, input[type="text"]:focus {
|
| 168 |
outline: none !important;
|
| 169 |
border: 1px solid var(--primary-glow) !important;
|
|
|
|
| 172 |
inset 0 0 30px rgba(0, 255, 247, 0.1) !important;
|
| 173 |
transform: scale(1.01);
|
| 174 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
"""
|
| 176 |
|
| 177 |
# ---------------------------
|
|
|
|
| 180 |
|
| 181 |
def respond(
|
| 182 |
message,
|
| 183 |
+
history: List[Dict[str, str]],
|
| 184 |
system_message,
|
| 185 |
max_tokens,
|
| 186 |
temperature,
|
| 187 |
top_p,
|
| 188 |
+
hf_token,
|
| 189 |
):
|
| 190 |
system_message = (
|
| 191 |
"You are a highly advanced AI system. "
|
|
|
|
| 211 |
temperature=temperature,
|
| 212 |
top_p=top_p,
|
| 213 |
):
|
| 214 |
+
choices = getattr(msg, "choices", [])
|
| 215 |
token = ""
|
| 216 |
|
| 217 |
+
if len(choices) and getattr(choices[0].delta, "content", None):
|
| 218 |
token = choices[0].delta.content
|
| 219 |
|
| 220 |
response += token
|
| 221 |
yield response
|
| 222 |
|
|
|
|
| 223 |
# ---------------------------
|
| 224 |
# INTERFACE INITIALIZATION
|
| 225 |
# ---------------------------
|
| 226 |
|
| 227 |
with gr.Blocks(css=custom_css, theme=gr.themes.Base()) as demo:
|
| 228 |
gr.HTML("<div id='title'>NEURAL QUANTUM INTERFACE</div>")
|
| 229 |
+
|
| 230 |
with gr.Row():
|
| 231 |
with gr.Column(scale=4):
|
| 232 |
chatbot = gr.Chatbot(
|
|
|
|
| 235 |
height=600,
|
| 236 |
elem_classes=["chatbot"]
|
| 237 |
)
|
| 238 |
+
|
| 239 |
with gr.Row():
|
| 240 |
msg = gr.Textbox(
|
| 241 |
label="INPUT STREAM",
|
|
|
|
| 243 |
scale=4
|
| 244 |
)
|
| 245 |
submit = gr.Button("TRANSMIT", scale=1)
|
| 246 |
+
|
| 247 |
with gr.Column(scale=1):
|
| 248 |
gr.LoginButton()
|
| 249 |
gr.Markdown("### SYSTEM PARAMETERS")
|
| 250 |
+
|
| 251 |
+
system_message_box = gr.Textbox(
|
| 252 |
value="Advanced AI System",
|
| 253 |
label="CORE DIRECTIVE"
|
| 254 |
)
|
|
|
|
| 273 |
step=0.05,
|
| 274 |
label="PROBABILITY THRESHOLD"
|
| 275 |
)
|
| 276 |
+
|
| 277 |
clear = gr.Button("RESET SYSTEM")
|
| 278 |
+
|
| 279 |
# Event handlers
|
| 280 |
msg.submit(
|
| 281 |
respond,
|
| 282 |
+
[msg, chatbot, system_message_box, max_tokens, temperature, top_p],
|
| 283 |
[chatbot]
|
| 284 |
)
|
| 285 |
submit.click(
|
| 286 |
respond,
|
| 287 |
+
[msg, chatbot, system_message_box, max_tokens, temperature, top_p],
|
| 288 |
[chatbot]
|
| 289 |
)
|
| 290 |
clear.click(lambda: None, None, chatbot, queue=False)
|
| 291 |
|
| 292 |
if __name__ == "__main__":
|
| 293 |
+
demo.launch()
|