Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -310,4 +310,500 @@ Remember: You're not trying to be helpful in a traditional sense - you're being
|
|
| 310 |
def creed_story_tool(self, situation: str = "mysterious") -> str:
|
| 311 |
"""MCP tool: Get a Creed story"""
|
| 312 |
if not self.model_loaded:
|
| 313 |
-
return "🧠 Creed's consciousness is still
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
def creed_story_tool(self, situation: str = "mysterious") -> str:
|
| 311 |
"""MCP tool: Get a Creed story"""
|
| 312 |
if not self.model_loaded:
|
| 313 |
+
return "🧠 Creed's consciousness is still loading..."
|
| 314 |
+
|
| 315 |
+
prompt = f"Tell me a {situation} story from your past."
|
| 316 |
+
|
| 317 |
+
# Generate a one-shot response
|
| 318 |
+
final_response = ""
|
| 319 |
+
for response in self.generate_response(prompt, []):
|
| 320 |
+
final_response = response
|
| 321 |
+
|
| 322 |
+
return final_response
|
| 323 |
+
|
| 324 |
+
def cleanup_gpu_memory(self):
|
| 325 |
+
"""Clean up GPU memory if using CUDA"""
|
| 326 |
+
if self.device == "cuda" and torch.cuda.is_available():
|
| 327 |
+
torch.cuda.empty_cache()
|
| 328 |
+
print(f"🧹 GPU Memory cleaned. Current: {torch.cuda.memory_allocated() // 1024**2} MB")
|
| 329 |
+
|
| 330 |
+
def main():
|
| 331 |
+
"""Initialize and launch the real Creed AI with modern styling"""
|
| 332 |
+
|
| 333 |
+
print("🎸 Initializing REAL Creed Bratton AI...")
|
| 334 |
+
print("📡 Loading Mark's trained model: phxdev/creed-qwen-0.5b-lora")
|
| 335 |
+
|
| 336 |
+
# Initialize Creed AI
|
| 337 |
+
creed_ai = CreedBrattonAI()
|
| 338 |
+
|
| 339 |
+
if SPACES_AVAILABLE:
|
| 340 |
+
gpu_placeholder()
|
| 341 |
+
print("✅ Spaces GPU compatibility enabled")
|
| 342 |
+
|
| 343 |
+
# Memory status if GPU available
|
| 344 |
+
if torch.cuda.is_available() and creed_ai.model_loaded:
|
| 345 |
+
print(f"🔥 Final GPU Memory: {torch.cuda.memory_allocated() // 1024**2} MB allocated")
|
| 346 |
+
print(f"📊 GPU Memory Reserved: {torch.cuda.memory_reserved() // 1024**2} MB reserved")
|
| 347 |
+
|
| 348 |
+
# Modern glassmorphism CSS
|
| 349 |
+
modern_css = """
|
| 350 |
+
/* Creed AI - Modern Glassmorphism Design */
|
| 351 |
+
:root {
|
| 352 |
+
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 353 |
+
--secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
| 354 |
+
--glass-bg: rgba(255, 255, 255, 0.08);
|
| 355 |
+
--glass-border: rgba(255, 255, 255, 0.18);
|
| 356 |
+
--text-primary: #ffffff;
|
| 357 |
+
--text-secondary: rgba(255, 255, 255, 0.8);
|
| 358 |
+
--accent-purple: #8b5cf6;
|
| 359 |
+
--accent-blue: #3b82f6;
|
| 360 |
+
--shadow-glow: 0 8px 32px rgba(139, 92, 246, 0.3);
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
/* Main container with animated background */
|
| 364 |
+
.gradio-container {
|
| 365 |
+
min-height: 100vh !important;
|
| 366 |
+
background: var(--primary-gradient) !important;
|
| 367 |
+
background-attachment: fixed !important;
|
| 368 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 369 |
+
color: var(--text-primary) !important;
|
| 370 |
+
padding: 20px !important;
|
| 371 |
+
position: relative !important;
|
| 372 |
+
overflow-x: hidden !important;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
.gradio-container::before {
|
| 376 |
+
content: '';
|
| 377 |
+
position: fixed;
|
| 378 |
+
top: 0;
|
| 379 |
+
left: 0;
|
| 380 |
+
width: 100%;
|
| 381 |
+
height: 100%;
|
| 382 |
+
background:
|
| 383 |
+
radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.3) 0%, transparent 50%),
|
| 384 |
+
radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.3) 0%, transparent 50%),
|
| 385 |
+
radial-gradient(circle at 40% 40%, rgba(167, 139, 250, 0.2) 0%, transparent 50%);
|
| 386 |
+
pointer-events: none;
|
| 387 |
+
z-index: -1;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
/* Floating particles animation */
|
| 391 |
+
.gradio-container::after {
|
| 392 |
+
content: '';
|
| 393 |
+
position: fixed;
|
| 394 |
+
top: 0;
|
| 395 |
+
left: 0;
|
| 396 |
+
width: 100%;
|
| 397 |
+
height: 100%;
|
| 398 |
+
background-image:
|
| 399 |
+
radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.3), transparent),
|
| 400 |
+
radial-gradient(2px 2px at 40px 70px, rgba(139, 92, 246, 0.4), transparent),
|
| 401 |
+
radial-gradient(1px 1px at 90px 40px, rgba(59, 130, 246, 0.3), transparent);
|
| 402 |
+
background-size: 120px 120px;
|
| 403 |
+
animation: float 20s ease-in-out infinite;
|
| 404 |
+
pointer-events: none;
|
| 405 |
+
z-index: -1;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
@keyframes float {
|
| 409 |
+
0%, 100% { transform: translateY(0px) rotate(0deg); }
|
| 410 |
+
50% { transform: translateY(-20px) rotate(180deg); }
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
/* Header styling */
|
| 414 |
+
.header {
|
| 415 |
+
background: var(--glass-bg) !important;
|
| 416 |
+
backdrop-filter: blur(20px) !important;
|
| 417 |
+
border: 1px solid var(--glass-border) !important;
|
| 418 |
+
border-radius: 24px !important;
|
| 419 |
+
padding: 32px !important;
|
| 420 |
+
margin-bottom: 24px !important;
|
| 421 |
+
text-align: center !important;
|
| 422 |
+
box-shadow: var(--shadow-glow) !important;
|
| 423 |
+
position: relative !important;
|
| 424 |
+
overflow: hidden !important;
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
.header::before {
|
| 428 |
+
content: '';
|
| 429 |
+
position: absolute;
|
| 430 |
+
top: 0;
|
| 431 |
+
left: 0;
|
| 432 |
+
right: 0;
|
| 433 |
+
height: 1px;
|
| 434 |
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
.header h1 {
|
| 438 |
+
font-size: 36px !important;
|
| 439 |
+
font-weight: 700 !important;
|
| 440 |
+
background: linear-gradient(135deg, #ffffff 0%, #a855f7 50%, #3b82f6 100%) !important;
|
| 441 |
+
-webkit-background-clip: text !important;
|
| 442 |
+
-webkit-text-fill-color: transparent !important;
|
| 443 |
+
background-clip: text !important;
|
| 444 |
+
margin: 0 0 12px 0 !important;
|
| 445 |
+
text-shadow: 0 0 30px rgba(168, 85, 247, 0.5) !important;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
.header p {
|
| 449 |
+
font-size: 16px !important;
|
| 450 |
+
color: var(--text-secondary) !important;
|
| 451 |
+
margin: 0 !important;
|
| 452 |
+
font-weight: 500 !important;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/* Info boxes with glass effect */
|
| 456 |
+
.info-box {
|
| 457 |
+
background: rgba(255, 255, 255, 0.06) !important;
|
| 458 |
+
backdrop-filter: blur(16px) !important;
|
| 459 |
+
border: 1px solid rgba(255, 255, 255, 0.12) !important;
|
| 460 |
+
border-radius: 16px !important;
|
| 461 |
+
padding: 20px !important;
|
| 462 |
+
margin: 16px 0 !important;
|
| 463 |
+
color: var(--text-secondary) !important;
|
| 464 |
+
font-size: 14px !important;
|
| 465 |
+
line-height: 1.6 !important;
|
| 466 |
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
.status-box {
|
| 470 |
+
background: rgba(16, 185, 129, 0.1) !important;
|
| 471 |
+
backdrop-filter: blur(16px) !important;
|
| 472 |
+
border: 1px solid rgba(16, 185, 129, 0.3) !important;
|
| 473 |
+
border-radius: 16px !important;
|
| 474 |
+
padding: 16px 20px !important;
|
| 475 |
+
margin: 16px 0 !important;
|
| 476 |
+
color: #10b981 !important;
|
| 477 |
+
font-weight: 600 !important;
|
| 478 |
+
box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2) !important;
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
/* Chat area styling */
|
| 482 |
+
.chat-area {
|
| 483 |
+
background: var(--glass-bg) !important;
|
| 484 |
+
backdrop-filter: blur(20px) !important;
|
| 485 |
+
border: 1px solid var(--glass-border) !important;
|
| 486 |
+
border-radius: 20px !important;
|
| 487 |
+
margin: 16px 0 !important;
|
| 488 |
+
overflow: hidden !important;
|
| 489 |
+
box-shadow: var(--shadow-glow) !important;
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
/* Tools section */
|
| 493 |
+
.tools-area {
|
| 494 |
+
background: var(--glass-bg) !important;
|
| 495 |
+
backdrop-filter: blur(20px) !important;
|
| 496 |
+
border: 1px solid var(--glass-border) !important;
|
| 497 |
+
border-radius: 20px !important;
|
| 498 |
+
padding: 28px !important;
|
| 499 |
+
margin: 24px 0 !important;
|
| 500 |
+
box-shadow: var(--shadow-glow) !important;
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
.tools-title {
|
| 504 |
+
font-size: 22px !important;
|
| 505 |
+
font-weight: 600 !important;
|
| 506 |
+
color: var(--text-primary) !important;
|
| 507 |
+
margin: 0 0 20px 0 !important;
|
| 508 |
+
padding-bottom: 12px !important;
|
| 509 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
|
| 510 |
+
background: linear-gradient(135deg, #ffffff 0%, #a855f7 100%) !important;
|
| 511 |
+
-webkit-background-clip: text !important;
|
| 512 |
+
-webkit-text-fill-color: transparent !important;
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
/* Form elements */
|
| 516 |
+
.gradio-textbox input,
|
| 517 |
+
.gradio-textbox textarea {
|
| 518 |
+
background: rgba(255, 255, 255, 0.08) !important;
|
| 519 |
+
backdrop-filter: blur(10px) !important;
|
| 520 |
+
border: 1px solid rgba(255, 255, 255, 0.16) !important;
|
| 521 |
+
color: var(--text-primary) !important;
|
| 522 |
+
border-radius: 12px !important;
|
| 523 |
+
padding: 12px 16px !important;
|
| 524 |
+
transition: all 0.3s ease !important;
|
| 525 |
+
font-size: 14px !important;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
.gradio-textbox input:focus,
|
| 529 |
+
.gradio-textbox textarea:focus {
|
| 530 |
+
border-color: var(--accent-purple) !important;
|
| 531 |
+
outline: none !important;
|
| 532 |
+
box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3) !important;
|
| 533 |
+
background: rgba(255, 255, 255, 0.12) !important;
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.gradio-textbox input::placeholder,
|
| 537 |
+
.gradio-textbox textarea::placeholder {
|
| 538 |
+
color: rgba(255, 255, 255, 0.5) !important;
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
/* Labels */
|
| 542 |
+
.gradio-container label {
|
| 543 |
+
color: var(--text-secondary) !important;
|
| 544 |
+
font-weight: 500 !important;
|
| 545 |
+
font-size: 14px !important;
|
| 546 |
+
margin-bottom: 6px !important;
|
| 547 |
+
display: block !important;
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
/* Buttons */
|
| 551 |
+
.gradio-container button {
|
| 552 |
+
background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%) !important;
|
| 553 |
+
color: var(--text-primary) !important;
|
| 554 |
+
border: none !important;
|
| 555 |
+
border-radius: 12px !important;
|
| 556 |
+
padding: 12px 24px !important;
|
| 557 |
+
font-weight: 600 !important;
|
| 558 |
+
cursor: pointer !important;
|
| 559 |
+
transition: all 0.3s ease !important;
|
| 560 |
+
box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4) !important;
|
| 561 |
+
backdrop-filter: blur(10px) !important;
|
| 562 |
+
min-height: 44px !important;
|
| 563 |
+
display: flex !important;
|
| 564 |
+
align-items: center !important;
|
| 565 |
+
justify-content: center !important;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
.gradio-container button:hover {
|
| 569 |
+
transform: translateY(-2px) !important;
|
| 570 |
+
box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6) !important;
|
| 571 |
+
background: linear-gradient(135deg, #9333ea 0%, #2563eb 100%) !important;
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
.gradio-container button:active {
|
| 575 |
+
transform: translateY(0px) !important;
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
/* Send button specific styling */
|
| 579 |
+
.gradio-container .gr-button {
|
| 580 |
+
background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%) !important;
|
| 581 |
+
border: 1px solid rgba(255, 255, 255, 0.2) !important;
|
| 582 |
+
color: white !important;
|
| 583 |
+
font-weight: 600 !important;
|
| 584 |
+
text-transform: none !important;
|
| 585 |
+
letter-spacing: 0.5px !important;
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
/* Chatbot specific styling */
|
| 589 |
+
.gradio-chatbot {
|
| 590 |
+
background: transparent !important;
|
| 591 |
+
border: none !important;
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
/* Footer */
|
| 595 |
+
.footer {
|
| 596 |
+
text-align: center !important;
|
| 597 |
+
padding: 28px !important;
|
| 598 |
+
color: var(--text-secondary) !important;
|
| 599 |
+
background: var(--glass-bg) !important;
|
| 600 |
+
backdrop-filter: blur(20px) !important;
|
| 601 |
+
border: 1px solid var(--glass-border) !important;
|
| 602 |
+
border-radius: 20px !important;
|
| 603 |
+
margin-top: 32px !important;
|
| 604 |
+
box-shadow: var(--shadow-glow) !important;
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
/* Scrollbar styling */
|
| 608 |
+
::-webkit-scrollbar {
|
| 609 |
+
width: 8px;
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
::-webkit-scrollbar-track {
|
| 613 |
+
background: rgba(255, 255, 255, 0.05);
|
| 614 |
+
border-radius: 4px;
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
::-webkit-scrollbar-thumb {
|
| 618 |
+
background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
|
| 619 |
+
border-radius: 4px;
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
::-webkit-scrollbar-thumb:hover {
|
| 623 |
+
background: linear-gradient(135deg, #9333ea, #2563eb);
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
/* Responsive design */
|
| 627 |
+
@media (max-width: 768px) {
|
| 628 |
+
.gradio-container {
|
| 629 |
+
padding: 12px !important;
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
.header {
|
| 633 |
+
padding: 20px !important;
|
| 634 |
+
border-radius: 16px !important;
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
.header h1 {
|
| 638 |
+
font-size: 28px !important;
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
.tools-area,
|
| 642 |
+
.chat-area {
|
| 643 |
+
border-radius: 16px !important;
|
| 644 |
+
padding: 20px !important;
|
| 645 |
+
}
|
| 646 |
+
}
|
| 647 |
+
"""
|
| 648 |
+
|
| 649 |
+
# Create wrapper function for proper chat handling
|
| 650 |
+
def respond(message, history):
|
| 651 |
+
"""Response handler for Gradio messages format"""
|
| 652 |
+
if not message.strip():
|
| 653 |
+
return "", history
|
| 654 |
+
|
| 655 |
+
# Convert messages format to simple tuples
|
| 656 |
+
simple_history = []
|
| 657 |
+
for i in range(0, len(history), 2):
|
| 658 |
+
if i + 1 < len(history):
|
| 659 |
+
user_msg = history[i].get('content', '') if isinstance(history[i], dict) else str(history[i])
|
| 660 |
+
bot_msg = history[i + 1].get('content', '') if isinstance(history[i + 1], dict) else str(history[i + 1])
|
| 661 |
+
if user_msg and bot_msg:
|
| 662 |
+
simple_history.append([user_msg, bot_msg])
|
| 663 |
+
|
| 664 |
+
# Generate response
|
| 665 |
+
for response_chunk in creed_ai.generate_response(message, simple_history):
|
| 666 |
+
# Create new history with the streaming response
|
| 667 |
+
new_history = history + [
|
| 668 |
+
{"role": "user", "content": message},
|
| 669 |
+
{"role": "assistant", "content": response_chunk}
|
| 670 |
+
]
|
| 671 |
+
yield "", new_history
|
| 672 |
+
|
| 673 |
+
# Create the interface with modern theme
|
| 674 |
+
with gr.Blocks(
|
| 675 |
+
title="🎸 Creed Bratton AI",
|
| 676 |
+
css=modern_css,
|
| 677 |
+
theme=gr.themes.Base() # Use base theme for better CSS control
|
| 678 |
+
) as demo:
|
| 679 |
+
|
| 680 |
+
# Modern header
|
| 681 |
+
gr.HTML(f"""
|
| 682 |
+
<div class="header">
|
| 683 |
+
<h1>🎸 Creed Bratton AI</h1>
|
| 684 |
+
<p>Powered by phxdev/creed-qwen-0.5b-lora • Running on {'🚀 GPU' if creed_ai.device == 'cuda' else '🖥️ CPU'}</p>
|
| 685 |
+
</div>
|
| 686 |
+
""")
|
| 687 |
+
|
| 688 |
+
# Model info with glass styling
|
| 689 |
+
gr.HTML("""
|
| 690 |
+
<div class="info-box">
|
| 691 |
+
<strong>Model:</strong> phxdev/creed-qwen-0.5b-lora<br>
|
| 692 |
+
<strong>Base:</strong> Qwen 0.5B + LoRA fine-tuning<br>
|
| 693 |
+
<strong>Tokens:</strong> <thinking>, <conspiracy>, <tangent>
|
| 694 |
+
</div>
|
| 695 |
+
""")
|
| 696 |
+
|
| 697 |
+
# MCP status
|
| 698 |
+
if os.environ.get('GRADIO_MCP_ENABLED'):
|
| 699 |
+
gr.HTML("""
|
| 700 |
+
<div class="status-box">
|
| 701 |
+
✓ MCP Server Active • Available as tool for Claude Desktop
|
| 702 |
+
</div>
|
| 703 |
+
""")
|
| 704 |
+
|
| 705 |
+
# Main chat interface with glass styling
|
| 706 |
+
with gr.Row(elem_classes="chat-area"):
|
| 707 |
+
chatbot = gr.Chatbot(
|
| 708 |
+
type='messages', # Use messages format (modern)
|
| 709 |
+
height=550,
|
| 710 |
+
show_copy_button=True,
|
| 711 |
+
show_share_button=False,
|
| 712 |
+
avatar_images=["👤", "🎸"],
|
| 713 |
+
bubble_full_width=False,
|
| 714 |
+
show_label=False,
|
| 715 |
+
placeholder="🎸 Creed is ready...",
|
| 716 |
+
container=False
|
| 717 |
+
)
|
| 718 |
+
|
| 719 |
+
# Input with explicit send button
|
| 720 |
+
with gr.Row():
|
| 721 |
+
with gr.Column(scale=7):
|
| 722 |
+
msg = gr.Textbox(
|
| 723 |
+
placeholder="Ask Creed anything...",
|
| 724 |
+
container=False,
|
| 725 |
+
submit_btn=False, # Disable built-in submit
|
| 726 |
+
stop_btn=False
|
| 727 |
+
)
|
| 728 |
+
with gr.Column(scale=1, min_width=100):
|
| 729 |
+
send_btn = gr.Button("Send", variant="primary", size="lg")
|
| 730 |
+
|
| 731 |
+
# Wire up the chat - both Enter key and Send button
|
| 732 |
+
msg.submit(
|
| 733 |
+
respond,
|
| 734 |
+
inputs=[msg, chatbot],
|
| 735 |
+
outputs=[msg, chatbot],
|
| 736 |
+
show_progress="hidden"
|
| 737 |
+
)
|
| 738 |
+
|
| 739 |
+
send_btn.click(
|
| 740 |
+
respond,
|
| 741 |
+
inputs=[msg, chatbot],
|
| 742 |
+
outputs=[msg, chatbot],
|
| 743 |
+
show_progress="hidden"
|
| 744 |
+
)
|
| 745 |
+
|
| 746 |
+
# MCP Tools section with glass styling
|
| 747 |
+
with gr.Row(elem_classes="tools-area"):
|
| 748 |
+
gr.HTML('<div class="tools-title">🛠️ MCP Tools</div>')
|
| 749 |
+
|
| 750 |
+
with gr.Row():
|
| 751 |
+
with gr.Column():
|
| 752 |
+
wisdom_topic = gr.Textbox(
|
| 753 |
+
label="Wisdom Topic",
|
| 754 |
+
placeholder="life, business, relationships..."
|
| 755 |
+
)
|
| 756 |
+
wisdom_output = gr.Textbox(
|
| 757 |
+
label="Creed's Response",
|
| 758 |
+
interactive=False,
|
| 759 |
+
lines=3
|
| 760 |
+
)
|
| 761 |
+
wisdom_btn = gr.Button("Ask Creed", variant="primary")
|
| 762 |
+
|
| 763 |
+
with gr.Column():
|
| 764 |
+
story_situation = gr.Textbox(
|
| 765 |
+
label="Story Request",
|
| 766 |
+
placeholder="Tell me about..."
|
| 767 |
+
)
|
| 768 |
+
story_output = gr.Textbox(
|
| 769 |
+
label="Creed's Story",
|
| 770 |
+
interactive=False,
|
| 771 |
+
lines=3
|
| 772 |
+
)
|
| 773 |
+
story_btn = gr.Button("Get Story", variant="primary")
|
| 774 |
+
|
| 775 |
+
# Wire up the tools
|
| 776 |
+
wisdom_btn.click(
|
| 777 |
+
creed_ai.creed_wisdom_tool,
|
| 778 |
+
inputs=[wisdom_topic],
|
| 779 |
+
outputs=[wisdom_output]
|
| 780 |
+
)
|
| 781 |
+
|
| 782 |
+
story_btn.click(
|
| 783 |
+
creed_ai.creed_story_tool,
|
| 784 |
+
inputs=[story_situation],
|
| 785 |
+
outputs=[story_output]
|
| 786 |
+
)
|
| 787 |
+
|
| 788 |
+
# Modern footer
|
| 789 |
+
gr.HTML("""
|
| 790 |
+
<div class="footer">
|
| 791 |
+
<strong>Creed Bratton AI</strong><br>
|
| 792 |
+
Model: phxdev/creed-qwen-0.5b-lora • Trained by Mark Scott<br>
|
| 793 |
+
<em>"Sometimes a guy's gotta ride the bull, am I right?"</em>
|
| 794 |
+
</div>
|
| 795 |
+
""")
|
| 796 |
+
|
| 797 |
+
# Launch with modern styling and public sharing
|
| 798 |
+
print("🚀 Launching Real Creed AI with modern glassmorphism design...")
|
| 799 |
+
|
| 800 |
+
demo.launch(
|
| 801 |
+
ssr_mode=False,
|
| 802 |
+
server_name="0.0.0.0",
|
| 803 |
+
server_port=7860,
|
| 804 |
+
share=True, # Create public link
|
| 805 |
+
show_error=True
|
| 806 |
+
)
|
| 807 |
+
|
| 808 |
+
if __name__ == "__main__":
|
| 809 |
+
main()
|