Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -425,114 +425,113 @@ def create_interface():
|
|
425 |
theme=gr.themes.Base(),
|
426 |
css="""
|
427 |
/* Import Google Fonts for better typography */
|
428 |
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
429 |
-
|
430 |
/* Dark theme styling with enhanced visuals */
|
431 |
.gradio-container {
|
432 |
-
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%) !important;
|
433 |
-
color: #ffffff !important; /* Ensure base text color is bright */
|
434 |
-
height: 100vh !important;
|
435 |
-
max-width: none !important;
|
436 |
-
padding: 0 !important;
|
437 |
-
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
438 |
}
|
439 |
|
440 |
/* Main container with animated background */
|
441 |
.main-container {
|
442 |
-
display: flex;
|
443 |
-
flex-direction: column;
|
444 |
-
height: 100vh;
|
445 |
background:
|
446 |
radial-gradient(circle at 20% 50%, rgba(255, 193, 7, 0.05) 0%, transparent 50%),
|
447 |
radial-gradient(circle at 80% 20%, rgba(0, 123, 255, 0.05) 0%, transparent 50%),
|
448 |
radial-gradient(circle at 40% 80%, rgba(255, 87, 34, 0.03) 0%, transparent 50%),
|
449 |
-
linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
|
450 |
-
animation: backgroundShift 15s ease-in-out infinite alternate;
|
451 |
}
|
452 |
|
453 |
@keyframes backgroundShift {
|
454 |
-
0% { filter: hue-rotate(0deg); }
|
455 |
-
100% { filter: hue-rotate(10deg); }
|
456 |
}
|
457 |
|
458 |
/* Enhanced Header with glow */
|
459 |
.header {
|
460 |
-
background: rgba(255, 193, 7, 0.08);
|
461 |
-
border-bottom: 2px solid transparent;
|
462 |
-
border-image: linear-gradient(90deg, rgba(255, 193, 7, 0.5), rgba(0, 123, 255, 0.3)) 1;
|
463 |
-
padding: 1.5rem 2rem;
|
464 |
-
backdrop-filter: blur(20px);
|
465 |
box-shadow:
|
466 |
0 4px 20px rgba(255, 193, 7, 0.1),
|
467 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
468 |
-
position: relative;
|
469 |
-
overflow: hidden;
|
470 |
}
|
471 |
|
472 |
.header::before {
|
473 |
-
content: '';
|
474 |
-
position: absolute;
|
475 |
-
top: 0;
|
476 |
-
left: -100%;
|
477 |
-
width: 100%;
|
478 |
-
height: 100%;
|
479 |
-
background: linear-gradient(90deg, transparent, rgba(255, 193, 7, 0.1), transparent);
|
480 |
-
animation: shimmer 3s ease-in-out infinite;
|
481 |
}
|
482 |
|
483 |
@keyframes shimmer {
|
484 |
-
0% { left: -100%; }
|
485 |
-
100% { left: 100%; }
|
486 |
}
|
487 |
|
488 |
.header h1 {
|
489 |
-
color: #ffc107;
|
490 |
-
margin: 0;
|
491 |
-
font-size: 2rem;
|
492 |
-
font-weight: 700;
|
493 |
text-shadow:
|
494 |
0 0 10px rgba(255, 193, 7, 0.3),
|
495 |
-
0 0 20px rgba(255, 193, 7, 0.2);
|
496 |
-
letter-spacing: -0.02em;
|
497 |
}
|
498 |
|
499 |
.header p {
|
500 |
-
color: #e0e0e0
|
501 |
-
margin: 0.5rem 0 0 0;
|
502 |
-
font-size: 1rem;
|
503 |
-
font-weight: 400;
|
504 |
-
opacity: 0.9;
|
505 |
}
|
506 |
|
507 |
/* Enhanced Chat container */
|
508 |
.chat-container {
|
509 |
-
flex: 1;
|
510 |
-
display: flex;
|
511 |
-
flex-direction: column;
|
512 |
-
max-width: 1200px;
|
513 |
-
margin: 0 auto;
|
514 |
-
width: 100%;
|
515 |
-
padding: 2rem;
|
516 |
-
height: calc(100vh - 200px) !important;
|
517 |
-
gap: 1.5rem;
|
518 |
}
|
519 |
|
520 |
/* Enhanced Chatbot with glow effect */
|
521 |
.gradio-chatbot {
|
522 |
-
height: 400px !important;
|
523 |
-
max-height: 400px !important;
|
524 |
-
background: rgba(45, 45, 45, 0.4) !important;
|
525 |
-
border: 2px solid rgba(255, 193, 7, 0.2) !important;
|
526 |
-
border-radius: 20px !important;
|
527 |
-
margin-bottom: 1rem;
|
528 |
-
overflow-y: auto !important;
|
529 |
box-shadow:
|
530 |
0 0 30px rgba(255, 193, 7, 0.15),
|
531 |
0 8px 32px rgba(0, 0, 0, 0.3),
|
532 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
|
533 |
-
backdrop-filter: blur(20px) !important;
|
534 |
-
position: relative;
|
535 |
-
animation: chatGlow 4s ease-in-out infinite alternate;
|
536 |
}
|
537 |
|
538 |
@keyframes chatGlow {
|
@@ -540,71 +539,71 @@ def create_interface():
|
|
540 |
box-shadow:
|
541 |
0 0 30px rgba(255, 193, 7, 0.15),
|
542 |
0 8px 32px rgba(0, 0, 0, 0.3),
|
543 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
544 |
}
|
545 |
100% {
|
546 |
box-shadow:
|
547 |
0 0 40px rgba(255, 193, 7, 0.25),
|
548 |
0 12px 40px rgba(0, 0, 0, 0.4),
|
549 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
550 |
}
|
551 |
}
|
552 |
|
553 |
/* Enhanced chat messages */
|
554 |
.message {
|
555 |
-
background: rgba(255, 255, 255, 0.05) !important;
|
556 |
-
border-radius: 16px !important;
|
557 |
-
padding: 1rem 1.5rem !important;
|
558 |
-
margin: 0.75rem 0 !important;
|
559 |
-
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
560 |
-
backdrop-filter: blur(10px) !important;
|
561 |
-
font-size: 0.95rem !important;
|
562 |
-
line-height: 1.6 !important;
|
563 |
-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
|
564 |
-
transition: all 0.3s ease !important;
|
565 |
-
color: #ffffff !important; /* Made brighter for all messages */
|
566 |
}
|
567 |
|
568 |
.message:hover {
|
569 |
-
transform: translateY(-1px) !important;
|
570 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
|
571 |
}
|
572 |
|
573 |
/* User message styling */
|
574 |
.message.user {
|
575 |
-
background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 193, 7, 0.05)) !important;
|
576 |
-
border-color: rgba(255, 193, 7, 0.2) !important;
|
577 |
-
margin-left: 15% !important;
|
578 |
box-shadow:
|
579 |
0 2px 10px rgba(255, 193, 7, 0.1),
|
580 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
|
581 |
}
|
582 |
|
583 |
/* Assistant message styling - important for streaming text */
|
584 |
.message.assistant {
|
585 |
-
background: linear-gradient(135deg, rgba(0, 123, 255, 0.08), rgba(0, 123, 255, 0.04)) !important;
|
586 |
-
border-color: rgba(0, 123, 255, 0.2) !important;
|
587 |
-
margin-right: 15% !important;
|
588 |
box-shadow:
|
589 |
0 2px 10px rgba(0, 123, 255, 0.1),
|
590 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
|
591 |
-
color: #ffffff !important; /* Ensures generated text is bright white */
|
592 |
}
|
593 |
|
594 |
/* Enhanced Input area with glow */
|
595 |
.input-area {
|
596 |
-
background: rgba(45, 45, 45, 0.6);
|
597 |
-
border-radius: 20px;
|
598 |
-
padding: 1.5rem;
|
599 |
-
border: 2px solid rgba(255, 193, 7, 0.2);
|
600 |
-
backdrop-filter: blur(20px);
|
601 |
-
position: sticky;
|
602 |
-
bottom: 0;
|
603 |
box-shadow:
|
604 |
0 0 25px rgba(255, 193, 7, 0.1),
|
605 |
0 8px 32px rgba(0, 0, 0, 0.2),
|
606 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
607 |
-
animation: inputGlow 3s ease-in-out infinite alternate;
|
608 |
}
|
609 |
|
610 |
@keyframes inputGlow {
|
@@ -612,217 +611,217 @@ def create_interface():
|
|
612 |
box-shadow:
|
613 |
0 0 25px rgba(255, 193, 7, 0.1),
|
614 |
0 8px 32px rgba(0, 0, 0, 0.2),
|
615 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
616 |
}
|
617 |
100% {
|
618 |
box-shadow:
|
619 |
0 0 35px rgba(255, 193, 7, 0.2),
|
620 |
0 12px 40px rgba(0, 0, 0, 0.3),
|
621 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
622 |
}
|
623 |
}
|
624 |
|
625 |
/* Enhanced File upload area */
|
626 |
.upload-area {
|
627 |
-
background: linear-gradient(135deg, rgba(255, 193, 7, 0.08), rgba(255, 193, 7, 0.04)) !important;
|
628 |
-
border: 2px dashed rgba(255, 193, 7, 0.4) !important;
|
629 |
-
border-radius: 16px !important;
|
630 |
-
padding: 1.5rem !important;
|
631 |
-
margin-bottom: 1.5rem !important;
|
632 |
-
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
633 |
-
backdrop-filter: blur(10px) !important;
|
634 |
box-shadow:
|
635 |
0 0 20px rgba(255, 193, 7, 0.05),
|
636 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
|
637 |
}
|
638 |
|
639 |
.upload-area:hover {
|
640 |
-
background: linear-gradient(135deg, rgba(255, 193, 7, 0.12), rgba(255, 193, 7, 0.06)) !important;
|
641 |
-
border-color: rgba(255, 193, 7, 0.6) !important;
|
642 |
box-shadow:
|
643 |
0 0 30px rgba(255, 193, 7, 0.15),
|
644 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
|
645 |
-
transform: translateY(-2px) !important;
|
646 |
}
|
647 |
|
648 |
/* Sidebar styling */
|
649 |
.sidebar {
|
650 |
-
background: rgba(30, 30, 30, 0.6) !important;
|
651 |
-
border-right: 2px solid rgba(255, 193, 7, 0.1) !important;
|
652 |
-
backdrop-filter: blur(15px) !important;
|
653 |
box-shadow:
|
654 |
inset -1px 0 0 rgba(255, 255, 255, 0.05),
|
655 |
-
4px 0 20px rgba(0, 0, 0, 0.1) !important;
|
656 |
}
|
657 |
|
658 |
/* Enhanced buttons with glow effects */
|
659 |
.send-btn {
|
660 |
-
background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important;
|
661 |
-
color: #000000 !important;
|
662 |
-
border: none !important;
|
663 |
-
border-radius: 12px !important;
|
664 |
-
font-weight: 600 !important;
|
665 |
-
min-height: 48px !important;
|
666 |
-
font-size: 0.95rem !important;
|
667 |
-
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
668 |
box-shadow:
|
669 |
0 4px 15px rgba(255, 193, 7, 0.3),
|
670 |
-
0 0 20px rgba(255, 193, 7, 0.2) !important;
|
671 |
-
position: relative;
|
672 |
-
overflow: hidden;
|
673 |
}
|
674 |
|
675 |
.send-btn::before {
|
676 |
-
content: '';
|
677 |
-
position: absolute;
|
678 |
-
top: 0;
|
679 |
-
left: -100%;
|
680 |
-
width: 100%;
|
681 |
-
height: 100%;
|
682 |
-
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
|
683 |
-
transition: left 0.5s;
|
684 |
}
|
685 |
|
686 |
.send-btn:hover::before {
|
687 |
-
left: 100%;
|
688 |
}
|
689 |
|
690 |
.send-btn:hover {
|
691 |
-
transform: translateY(-2px) !important;
|
692 |
box-shadow:
|
693 |
0 8px 25px rgba(255, 193, 7, 0.4),
|
694 |
-
0 0 30px rgba(255, 193, 7, 0.3) !important;
|
695 |
}
|
696 |
|
697 |
.primary-btn {
|
698 |
-
background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important;
|
699 |
-
color: #000000 !important;
|
700 |
-
border: none !important;
|
701 |
-
border-radius: 12px !important;
|
702 |
-
font-weight: 600 !important;
|
703 |
-
padding: 0.75rem 1.5rem !important;
|
704 |
-
font-size: 0.95rem !important;
|
705 |
-
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
706 |
box-shadow:
|
707 |
0 4px 15px rgba(255, 193, 7, 0.3),
|
708 |
-
0 0 20px rgba(255, 193, 7, 0.2) !important;
|
709 |
}
|
710 |
|
711 |
.primary-btn:hover {
|
712 |
-
transform: translateY(-2px) !important;
|
713 |
box-shadow:
|
714 |
0 8px 25px rgba(255, 193, 7, 0.4),
|
715 |
-
0 0 30px rgba(255, 193, 7, 0.3) !important;
|
716 |
}
|
717 |
|
718 |
/* Enhanced Text inputs with glow */
|
719 |
.gradio-textbox input, .gradio-textbox textarea {
|
720 |
-
background: rgba(45, 45, 45, 0.8) !important;
|
721 |
-
color: #ffffff !important;
|
722 |
-
border: 2px solid rgba(255, 193, 7, 0.2) !important;
|
723 |
-
border-radius: 12px !important;
|
724 |
-
font-size: 0.95rem !important;
|
725 |
-
padding: 0.75rem 1rem !important;
|
726 |
-
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
727 |
-
backdrop-filter: blur(10px) !important;
|
728 |
-
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
|
729 |
}
|
730 |
|
731 |
.gradio-textbox input:focus, .gradio-textbox textarea:focus {
|
732 |
-
border-color: rgba(255, 193, 7, 0.5) !important;
|
733 |
box-shadow:
|
734 |
0 0 20px rgba(255, 193, 7, 0.2),
|
735 |
-
inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
|
736 |
-
outline: none !important;
|
737 |
}
|
738 |
|
739 |
/* Enhanced Processing indicator */
|
740 |
.processing-indicator {
|
741 |
-
background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.08));
|
742 |
-
border: 2px solid rgba(255, 193, 7, 0.3);
|
743 |
-
border-radius: 12px;
|
744 |
-
padding: 1rem 1.5rem;
|
745 |
-
margin: 1rem 0;
|
746 |
-
color: #ffc107;
|
747 |
-
text-align: center;
|
748 |
-
font-weight: 500;
|
749 |
-
backdrop-filter: blur(10px);
|
750 |
box-shadow:
|
751 |
0 0 25px rgba(255, 193, 7, 0.1),
|
752 |
-
inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
753 |
-
animation: processingPulse 2s ease-in-out infinite;
|
754 |
}
|
755 |
|
756 |
@keyframes processingPulse {
|
757 |
-
0%, 100% { opacity: 1; }
|
758 |
-
50% { opacity: 0.8; }
|
759 |
}
|
760 |
|
761 |
/* Enhanced Input row styling */
|
762 |
.input-row {
|
763 |
-
display: flex !important;
|
764 |
-
gap: 12px !important;
|
765 |
-
align-items: end !important;
|
766 |
}
|
767 |
|
768 |
/* Message input */
|
769 |
.message-input {
|
770 |
-
flex: 1 !important;
|
771 |
-
min-height: 48px !important;
|
772 |
}
|
773 |
|
774 |
/* Markdown content styling - applies to text within gr.Markdown components */
|
775 |
.markdown-content {
|
776 |
-
color: #
|
777 |
-
line-height: 1.6 !important;
|
778 |
-
font-size: 0.95rem !important;
|
779 |
}
|
780 |
|
781 |
.markdown-content h1, .markdown-content h2, .markdown-content h3 {
|
782 |
-
color: #ffc107 !important;
|
783 |
-
margin-top: 1.5rem !important;
|
784 |
-
margin-bottom: 0.5rem !important;
|
785 |
}
|
786 |
|
787 |
.markdown-content code {
|
788 |
-
background: rgba(255, 193, 7, 0.1) !important;
|
789 |
-
color: #ffc107 !important;
|
790 |
-
padding: 0.2rem 0.4rem !important;
|
791 |
-
border-radius: 4px !important;
|
792 |
}
|
793 |
|
794 |
.markdown-content pre {
|
795 |
-
background: rgba(0, 0, 0, 0.3) !important;
|
796 |
-
border: 1px solid rgba(255, 193, 7, 0.2) !important;
|
797 |
-
border-radius: 8px !important;
|
798 |
-
padding: 1rem !important;
|
799 |
-
margin: 1rem 0 !important;
|
800 |
}
|
801 |
|
802 |
/* Examples styling */
|
803 |
.examples {
|
804 |
-
background: rgba(45, 45, 45, 0.3) !important;
|
805 |
-
border-radius: 12px !important;
|
806 |
-
padding: 1rem !important;
|
807 |
-
border: 1px solid rgba(255, 193, 7, 0.1) !important;
|
808 |
-
backdrop-filter: blur(10px) !important;
|
809 |
-
color: #
|
810 |
}
|
811 |
|
812 |
/* General paragraph text and Gradio HTML components (for architecture text) */
|
813 |
.gradio-container p,
|
814 |
.gradio-container .gr-html {
|
815 |
-
color: #
|
816 |
}
|
817 |
|
818 |
/* Loading animation */
|
819 |
@keyframes loading {
|
820 |
-
0% { transform: rotate(0deg); }
|
821 |
-
100% { transform: rotate(360deg); }
|
822 |
}
|
823 |
|
824 |
.loading {
|
825 |
-
animation: loading 2s linear infinite;
|
826 |
}
|
827 |
|
828 |
/* Responsive design */
|
@@ -835,106 +834,88 @@ def create_interface():
|
|
835 |
with gr.Column():
|
836 |
gr.HTML("""
|
837 |
<div class="header">
|
838 |
-
<h1> Agentic RAG Assistant</h1>
|
839 |
<p>Upload documents and ask questions - powered by Multi-Agent Architecture with streaming responses</p>
|
840 |
</div>
|
841 |
""")
|
842 |
|
843 |
# Main layout with sidebar and chat
|
844 |
-
with gr.Row():
|
845 |
# Left sidebar for file upload
|
846 |
with gr.Column(scale=1, elem_classes=["sidebar"]):
|
847 |
-
gr.Markdown("###
|
848 |
|
849 |
file_upload = gr.File(
|
850 |
-
file_count="multiple",
|
851 |
-
file_types=[".pdf", ".pptx", ".csv", ".docx", ".txt", ".md"],
|
852 |
-
label="
|
853 |
-
elem_classes=["upload-area"]
|
854 |
)
|
855 |
|
856 |
-
processing_status = gr.HTML(visible=False)
|
857 |
|
858 |
process_btn = gr.Button(
|
859 |
" Process Documents",
|
860 |
variant="primary",
|
861 |
-
elem_classes=["primary-btn"]
|
862 |
)
|
863 |
|
864 |
-
|
865 |
-
### Architecture
|
866 |
-
|
867 |
-
**Multi-Agent System:**
|
868 |
-
- **IngestionAgent**: Document parsing
|
869 |
-
- **RetrievalAgent**: Semantic search
|
870 |
-
- **LLMAgent**: Response generation
|
871 |
-
- **CoordinatorAgent**: Workflow orchestration
|
872 |
-
|
873 |
-
**Features:**
|
874 |
-
- Streaming responses
|
875 |
-
- Multi-format support
|
876 |
-
- Context-aware answers
|
877 |
-
- Real-time processing
|
878 |
-
""", elem_classes=["markdown-content"])
|
879 |
|
880 |
# Right side - Chat interface
|
881 |
with gr.Column(scale=2):
|
882 |
-
gr.Markdown("###
|
883 |
|
884 |
# Chatbot with enhanced styling
|
885 |
-
chatbot = gr.Chatbot(
|
886 |
-
height=400,
|
887 |
-
elem_classes=["gradio-chatbot"],
|
888 |
-
show_copy_button=True,
|
889 |
-
type="messages",
|
890 |
-
placeholder="Upload documents , then start chatting! Ask me anything about your documents.",
|
891 |
-
avatar_images=("
|
892 |
)
|
893 |
|
894 |
# Input area with improved layout
|
895 |
with gr.Row(elem_classes=["input-row"]):
|
896 |
-
msg_input = gr.Textbox(
|
897 |
-
placeholder="Ask about your documents...",
|
898 |
-
label="Message",
|
899 |
-
scale=4,
|
900 |
-
elem_classes=["message-input"],
|
901 |
-
show_label=False,
|
902 |
-
autofocus=True
|
903 |
)
|
904 |
-
send_btn = gr.Button(
|
905 |
" Send",
|
906 |
scale=1,
|
907 |
-
elem_classes=["send-btn"],
|
908 |
-
size="sm"
|
909 |
)
|
910 |
|
911 |
-
# Enhanced Examples
|
912 |
gr.Examples(
|
913 |
examples=[
|
914 |
-
"
|
915 |
-
"
|
916 |
-
" What metrics are mentioned?",
|
917 |
-
" What are the recommendations?",
|
918 |
-
" Find specific information about...",
|
919 |
-
" Create a summary of the content"
|
920 |
],
|
921 |
-
inputs=msg_input,
|
922 |
-
label=" Example Questions",
|
923 |
-
|
924 |
)
|
925 |
|
926 |
# State to track document processing
|
927 |
doc_processed = gr.State(False)
|
928 |
|
929 |
# Event handlers
|
930 |
-
def handle_file_upload_and_process(files):
|
931 |
if not files:
|
932 |
return gr.update(visible=False), False
|
933 |
|
934 |
# Show processing indicator
|
935 |
processing_html = f"""
|
936 |
<div class="processing-indicator">
|
937 |
-
|
938 |
</div>
|
939 |
"""
|
940 |
|
@@ -943,8 +924,8 @@ def create_interface():
|
|
943 |
result = coordinator_agent.process_files(files)
|
944 |
|
945 |
# Wait a moment for processing to complete
|
946 |
-
import time
|
947 |
-
time.sleep(3)
|
948 |
|
949 |
success_html = """
|
950 |
<div style="background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.08));
|
@@ -953,7 +934,7 @@ def create_interface():
|
|
953 |
box-shadow: 0 0 20px rgba(76, 175, 80, 0.1);">
|
954 |
Documents processed successfully! You can now ask questions about your content.
|
955 |
</div>
|
956 |
-
"""
|
957 |
return gr.update(value=success_html, visible=True), True
|
958 |
|
959 |
except Exception as e:
|
@@ -964,28 +945,28 @@ def create_interface():
|
|
964 |
box-shadow: 0 0 20px rgba(244, 67, 54, 0.1);">
|
965 |
Error processing documents: {str(e)}
|
966 |
</div>
|
967 |
-
"""
|
968 |
return gr.update(value=error_html, visible=True), False
|
969 |
|
970 |
-
def respond(message, history, doc_ready):
|
971 |
if not doc_ready:
|
972 |
# Show error message
|
973 |
history.append({"role": "user", "content": message})
|
974 |
history.append({"role": "assistant", "content": " Please upload and process documents first before asking questions."})
|
975 |
-
return history, ""
|
976 |
|
977 |
if not message.strip():
|
978 |
return history, message
|
979 |
|
980 |
# Add user message
|
981 |
history.append({"role": "user", "content": message})
|
982 |
-
history.append({"role": "assistant", "content": ""})
|
983 |
|
984 |
# Stream response
|
985 |
try:
|
986 |
for token in coordinator_agent.handle_query(message, history):
|
987 |
history[-1]["content"] += token
|
988 |
-
yield history, ""
|
989 |
except Exception as e:
|
990 |
history[-1]["content"] = f" Error generating response: {str(e)}"
|
991 |
yield history, ""
|
@@ -993,8 +974,8 @@ def create_interface():
|
|
993 |
# Event bindings
|
994 |
process_btn.click(
|
995 |
handle_file_upload_and_process,
|
996 |
-
inputs=[file_upload],
|
997 |
-
outputs=[processing_status, doc_processed]
|
998 |
)
|
999 |
|
1000 |
send_btn.click(
|
@@ -1004,7 +985,7 @@ def create_interface():
|
|
1004 |
show_progress=True
|
1005 |
)
|
1006 |
|
1007 |
-
msg_input.submit(
|
1008 |
respond,
|
1009 |
inputs=[msg_input, chatbot, doc_processed],
|
1010 |
outputs=[chatbot, msg_input],
|
@@ -1012,7 +993,7 @@ def create_interface():
|
|
1012 |
)
|
1013 |
|
1014 |
return iface
|
1015 |
-
|
1016 |
# Launch the application
|
1017 |
if __name__ == "__main__":
|
1018 |
demo = create_interface()
|
|
|
425 |
theme=gr.themes.Base(),
|
426 |
css="""
|
427 |
/* Import Google Fonts for better typography */
|
428 |
+
[cite_start]@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap'); [cite: 52]
|
|
|
429 |
/* Dark theme styling with enhanced visuals */
|
430 |
.gradio-container {
|
431 |
+
[cite_start]background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%) !important; [cite: 52]
|
432 |
+
color: #ffffff !important; [cite_start]/* Ensure base text color is bright */ [cite: 53]
|
433 |
+
[cite_start]height: 100vh !important; [cite: 53]
|
434 |
+
[cite_start]max-width: none !important; [cite: 54]
|
435 |
+
[cite_start]padding: 0 !important; [cite: 54]
|
436 |
+
[cite_start]font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important; [cite: 55]
|
437 |
}
|
438 |
|
439 |
/* Main container with animated background */
|
440 |
.main-container {
|
441 |
+
[cite_start]display: flex; [cite: 56]
|
442 |
+
[cite_start]flex-direction: column; [cite: 56]
|
443 |
+
[cite_start]height: 100vh; [cite: 56]
|
444 |
background:
|
445 |
radial-gradient(circle at 20% 50%, rgba(255, 193, 7, 0.05) 0%, transparent 50%),
|
446 |
radial-gradient(circle at 80% 20%, rgba(0, 123, 255, 0.05) 0%, transparent 50%),
|
447 |
radial-gradient(circle at 40% 80%, rgba(255, 87, 34, 0.03) 0%, transparent 50%),
|
448 |
+
[cite_start]linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%); [cite: 56]
|
449 |
+
[cite_start]animation: backgroundShift 15s ease-in-out infinite alternate; [cite: 57]
|
450 |
}
|
451 |
|
452 |
@keyframes backgroundShift {
|
453 |
+
[cite_start]0% { filter: hue-rotate(0deg); [cite: 58] }
|
454 |
+
[cite_start]100% { filter: hue-rotate(10deg); [cite: 59] }
|
455 |
}
|
456 |
|
457 |
/* Enhanced Header with glow */
|
458 |
.header {
|
459 |
+
[cite_start]background: rgba(255, 193, 7, 0.08); [cite: 60]
|
460 |
+
[cite_start]border-bottom: 2px solid transparent; [cite: 60]
|
461 |
+
[cite_start]border-image: linear-gradient(90deg, rgba(255, 193, 7, 0.5), rgba(0, 123, 255, 0.3)) 1; [cite: 60]
|
462 |
+
[cite_start]padding: 1.5rem 2rem; [cite: 60]
|
463 |
+
[cite_start]backdrop-filter: blur(20px); [cite: 61]
|
464 |
box-shadow:
|
465 |
0 4px 20px rgba(255, 193, 7, 0.1),
|
466 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.1); [cite: 61]
|
467 |
+
[cite_start]position: relative; [cite: 62]
|
468 |
+
[cite_start]overflow: hidden; [cite: 62]
|
469 |
}
|
470 |
|
471 |
.header::before {
|
472 |
+
[cite_start]content: ''; [cite: 63]
|
473 |
+
[cite_start]position: absolute; [cite: 63]
|
474 |
+
[cite_start]top: 0; [cite: 63]
|
475 |
+
[cite_start]left: -100%; [cite: 63]
|
476 |
+
[cite_start]width: 100%; [cite: 63]
|
477 |
+
[cite_start]height: 100%; [cite: 63]
|
478 |
+
[cite_start]background: linear-gradient(90deg, transparent, rgba(255, 193, 7, 0.1), transparent); [cite: 63]
|
479 |
+
[cite_start]animation: shimmer 3s ease-in-out infinite; [cite: 64]
|
480 |
}
|
481 |
|
482 |
@keyframes shimmer {
|
483 |
+
[cite_start]0% { left: -100%; [cite: 65] }
|
484 |
+
[cite_start]100% { left: 100%; [cite: 66] }
|
485 |
}
|
486 |
|
487 |
.header h1 {
|
488 |
+
[cite_start]color: #ffc107; [cite: 67]
|
489 |
+
[cite_start]margin: 0; [cite: 67]
|
490 |
+
[cite_start]font-size: 2rem; [cite: 67]
|
491 |
+
[cite_start]font-weight: 700; [cite: 67]
|
492 |
text-shadow:
|
493 |
0 0 10px rgba(255, 193, 7, 0.3),
|
494 |
+
[cite_start]0 0 20px rgba(255, 193, 7, 0.2); [cite: 67]
|
495 |
+
[cite_start]letter-spacing: -0.02em; [cite: 68]
|
496 |
}
|
497 |
|
498 |
.header p {
|
499 |
+
color: #ffffff; [cite_start]/* UPDATED from #e0e0e0 */ [cite: 69]
|
500 |
+
[cite_start]margin: 0.5rem 0 0 0; [cite: 69]
|
501 |
+
[cite_start]font-size: 1rem; [cite: 69]
|
502 |
+
[cite_start]font-weight: 400; [cite: 69]
|
503 |
+
[cite_start]opacity: 0.9; [cite: 70]
|
504 |
}
|
505 |
|
506 |
/* Enhanced Chat container */
|
507 |
.chat-container {
|
508 |
+
[cite_start]flex: 1; [cite: 71]
|
509 |
+
[cite_start]display: flex; [cite: 71]
|
510 |
+
[cite_start]flex-direction: column; [cite: 71]
|
511 |
+
[cite_start]max-width: 1200px; [cite: 71]
|
512 |
+
[cite_start]margin: 0 auto; [cite: 71]
|
513 |
+
[cite_start]width: 100%; [cite: 71]
|
514 |
+
[cite_start]padding: 2rem; [cite: 71]
|
515 |
+
[cite_start]height: calc(100vh - 200px) !important; [cite: 71]
|
516 |
+
[cite_start]gap: 1.5rem; [cite: 72]
|
517 |
}
|
518 |
|
519 |
/* Enhanced Chatbot with glow effect */
|
520 |
.gradio-chatbot {
|
521 |
+
[cite_start]height: 400px !important; [cite: 73]
|
522 |
+
[cite_start]max-height: 400px !important; [cite: 73]
|
523 |
+
[cite_start]background: rgba(45, 45, 45, 0.4) !important; [cite: 73]
|
524 |
+
[cite_start]border: 2px solid rgba(255, 193, 7, 0.2) !important; [cite: 73]
|
525 |
+
[cite_start]border-radius: 20px !important; [cite: 74]
|
526 |
+
[cite_start]margin-bottom: 1rem; [cite: 74]
|
527 |
+
[cite_start]overflow-y: auto !important; [cite: 74]
|
528 |
box-shadow:
|
529 |
0 0 30px rgba(255, 193, 7, 0.15),
|
530 |
0 8px 32px rgba(0, 0, 0, 0.3),
|
531 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.05) !important; [cite: 74]
|
532 |
+
[cite_start]backdrop-filter: blur(20px) !important; [cite: 75]
|
533 |
+
[cite_start]position: relative; [cite: 75]
|
534 |
+
[cite_start]animation: chatGlow 4s ease-in-out infinite alternate; [cite: 76]
|
535 |
}
|
536 |
|
537 |
@keyframes chatGlow {
|
|
|
539 |
box-shadow:
|
540 |
0 0 30px rgba(255, 193, 7, 0.15),
|
541 |
0 8px 32px rgba(0, 0, 0, 0.3),
|
542 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.05); [cite: 77]
|
543 |
}
|
544 |
100% {
|
545 |
box-shadow:
|
546 |
0 0 40px rgba(255, 193, 7, 0.25),
|
547 |
0 12px 40px rgba(0, 0, 0, 0.4),
|
548 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.08); [cite: 78]
|
549 |
}
|
550 |
}
|
551 |
|
552 |
/* Enhanced chat messages */
|
553 |
.message {
|
554 |
+
[cite_start]background: rgba(255, 255, 255, 0.05) !important; [cite: 79]
|
555 |
+
[cite_start]border-radius: 16px !important; [cite: 79]
|
556 |
+
[cite_start]padding: 1rem 1.5rem !important; [cite: 79]
|
557 |
+
[cite_start]margin: 0.75rem 0 !important; [cite: 79]
|
558 |
+
[cite_start]border: 1px solid rgba(255, 255, 255, 0.1) !important; [cite: 80]
|
559 |
+
[cite_start]backdrop-filter: blur(10px) !important; [cite: 80]
|
560 |
+
[cite_start]font-size: 0.95rem !important; [cite: 80]
|
561 |
+
[cite_start]line-height: 1.6 !important; [cite: 80]
|
562 |
+
[cite_start]box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important; [cite: 81]
|
563 |
+
[cite_start]transition: all 0.3s ease !important; [cite: 81]
|
564 |
+
color: #ffffff !important; [cite_start]/* Made brighter for all messages */ [cite: 81]
|
565 |
}
|
566 |
|
567 |
.message:hover {
|
568 |
+
[cite_start]transform: translateY(-1px) !important; [cite: 82]
|
569 |
+
[cite_start]box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important; [cite: 82]
|
570 |
}
|
571 |
|
572 |
/* User message styling */
|
573 |
.message.user {
|
574 |
+
[cite_start]background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 193, 7, 0.05)) !important; [cite: 83]
|
575 |
+
[cite_start]border-color: rgba(255, 193, 7, 0.2) !important; [cite: 83]
|
576 |
+
[cite_start]margin-left: 15% !important; [cite: 83]
|
577 |
box-shadow:
|
578 |
0 2px 10px rgba(255, 193, 7, 0.1),
|
579 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.05) !important; [cite: 84]
|
580 |
}
|
581 |
|
582 |
/* Assistant message styling - important for streaming text */
|
583 |
.message.assistant {
|
584 |
+
[cite_start]background: linear-gradient(135deg, rgba(0, 123, 255, 0.08), rgba(0, 123, 255, 0.04)) !important; [cite: 85]
|
585 |
+
[cite_start]border-color: rgba(0, 123, 255, 0.2) !important; [cite: 85]
|
586 |
+
[cite_start]margin-right: 15% !important; [cite: 85]
|
587 |
box-shadow:
|
588 |
0 2px 10px rgba(0, 123, 255, 0.1),
|
589 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.05) !important; [cite: 86]
|
590 |
+
color: #ffffff !important; [cite_start]/* Ensures generated text is bright white */ [cite: 86]
|
591 |
}
|
592 |
|
593 |
/* Enhanced Input area with glow */
|
594 |
.input-area {
|
595 |
+
[cite_start]background: rgba(45, 45, 45, 0.6); [cite: 87]
|
596 |
+
[cite_start]border-radius: 20px; [cite: 87]
|
597 |
+
[cite_start]padding: 1.5rem; [cite: 87]
|
598 |
+
[cite_start]border: 2px solid rgba(255, 193, 7, 0.2); [cite: 87]
|
599 |
+
[cite_start]backdrop-filter: blur(20px); [cite: 87]
|
600 |
+
[cite_start]position: sticky; [cite: 87]
|
601 |
+
[cite_start]bottom: 0; [cite: 88]
|
602 |
box-shadow:
|
603 |
0 0 25px rgba(255, 193, 7, 0.1),
|
604 |
0 8px 32px rgba(0, 0, 0, 0.2),
|
605 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.05); [cite: 89]
|
606 |
+
[cite_start]animation: inputGlow 3s ease-in-out infinite alternate; [cite: 89]
|
607 |
}
|
608 |
|
609 |
@keyframes inputGlow {
|
|
|
611 |
box-shadow:
|
612 |
0 0 25px rgba(255, 193, 7, 0.1),
|
613 |
0 8px 32px rgba(0, 0, 0, 0.2),
|
614 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.05); [cite: 90]
|
615 |
}
|
616 |
100% {
|
617 |
box-shadow:
|
618 |
0 0 35px rgba(255, 193, 7, 0.2),
|
619 |
0 12px 40px rgba(0, 0, 0, 0.3),
|
620 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.08); [cite: 91]
|
621 |
}
|
622 |
}
|
623 |
|
624 |
/* Enhanced File upload area */
|
625 |
.upload-area {
|
626 |
+
[cite_start]background: linear-gradient(135deg, rgba(255, 193, 7, 0.08), rgba(255, 193, 7, 0.04)) !important; [cite: 92]
|
627 |
+
[cite_start]border: 2px dashed rgba(255, 193, 7, 0.4) !important; [cite: 92]
|
628 |
+
[cite_start]border-radius: 16px !important; [cite: 92]
|
629 |
+
[cite_start]padding: 1.5rem !important; [cite: 92]
|
630 |
+
[cite_start]margin-bottom: 1.5rem !important; [cite: 93]
|
631 |
+
[cite_start]transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important; [cite: 93]
|
632 |
+
[cite_start]backdrop-filter: blur(10px) !important; [cite: 94]
|
633 |
box-shadow:
|
634 |
0 0 20px rgba(255, 193, 7, 0.05),
|
635 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.05) !important; [cite: 95]
|
636 |
}
|
637 |
|
638 |
.upload-area:hover {
|
639 |
+
[cite_start]background: linear-gradient(135deg, rgba(255, 193, 7, 0.12), rgba(255, 193, 7, 0.06)) !important; [cite: 96]
|
640 |
+
[cite_start]border-color: rgba(255, 193, 7, 0.6) !important; [cite: 96]
|
641 |
box-shadow:
|
642 |
0 0 30px rgba(255, 193, 7, 0.15),
|
643 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.08) !important; [cite: 97]
|
644 |
+
[cite_start]transform: translateY(-2px) !important; [cite: 97]
|
645 |
}
|
646 |
|
647 |
/* Sidebar styling */
|
648 |
.sidebar {
|
649 |
+
[cite_start]background: rgba(30, 30, 30, 0.6) !important; [cite: 98]
|
650 |
+
[cite_start]border-right: 2px solid rgba(255, 193, 7, 0.1) !important; [cite: 98]
|
651 |
+
[cite_start]backdrop-filter: blur(15px) !important; [cite: 99]
|
652 |
box-shadow:
|
653 |
inset -1px 0 0 rgba(255, 255, 255, 0.05),
|
654 |
+
[cite_start]4px 0 20px rgba(0, 0, 0, 0.1) !important; [cite: 100]
|
655 |
}
|
656 |
|
657 |
/* Enhanced buttons with glow effects */
|
658 |
.send-btn {
|
659 |
+
[cite_start]background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important; [cite: 101]
|
660 |
+
[cite_start]color: #000000 !important; [cite: 101]
|
661 |
+
[cite_start]border: none !important; [cite: 101]
|
662 |
+
[cite_start]border-radius: 12px !important; [cite: 101]
|
663 |
+
[cite_start]font-weight: 600 !important; [cite: 101]
|
664 |
+
[cite_start]min-height: 48px !important; [cite: 101]
|
665 |
+
[cite_start]font-size: 0.95rem !important; [cite: 102]
|
666 |
+
[cite_start]transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important; [cite: 102]
|
667 |
box-shadow:
|
668 |
0 4px 15px rgba(255, 193, 7, 0.3),
|
669 |
+
[cite_start]0 0 20px rgba(255, 193, 7, 0.2) !important; [cite: 103]
|
670 |
+
[cite_start]position: relative; [cite: 103]
|
671 |
+
[cite_start]overflow: hidden; [cite: 103]
|
672 |
}
|
673 |
|
674 |
.send-btn::before {
|
675 |
+
[cite_start]content: ''; [cite: 104]
|
676 |
+
[cite_start]position: absolute; [cite: 104]
|
677 |
+
[cite_start]top: 0; [cite: 104]
|
678 |
+
[cite_start]left: -100%; [cite: 104]
|
679 |
+
[cite_start]width: 100%; [cite: 104]
|
680 |
+
[cite_start]height: 100%; [cite: 104]
|
681 |
+
[cite_start]background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); [cite: 105]
|
682 |
+
[cite_start]transition: left 0.5s; [cite: 105]
|
683 |
}
|
684 |
|
685 |
.send-btn:hover::before {
|
686 |
+
[cite_start]left: 100%; [cite: 106]
|
687 |
}
|
688 |
|
689 |
.send-btn:hover {
|
690 |
+
[cite_start]transform: translateY(-2px) !important; [cite: 107]
|
691 |
box-shadow:
|
692 |
0 8px 25px rgba(255, 193, 7, 0.4),
|
693 |
+
[cite_start]0 0 30px rgba(255, 193, 7, 0.3) !important; [cite: 108]
|
694 |
}
|
695 |
|
696 |
.primary-btn {
|
697 |
+
[cite_start]background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important; [cite: 109]
|
698 |
+
[cite_start]color: #000000 !important; [cite: 109]
|
699 |
+
[cite_start]border: none !important; [cite: 109]
|
700 |
+
[cite_start]border-radius: 12px !important; [cite: 109]
|
701 |
+
[cite_start]font-weight: 600 !important; [cite: 109]
|
702 |
+
[cite_start]padding: 0.75rem 1.5rem !important; [cite: 109]
|
703 |
+
[cite_start]font-size: 0.95rem !important; [cite: 110]
|
704 |
+
[cite_start]transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important; [cite: 110]
|
705 |
box-shadow:
|
706 |
0 4px 15px rgba(255, 193, 7, 0.3),
|
707 |
+
[cite_start]0 0 20px rgba(255, 193, 7, 0.2) !important; [cite: 111]
|
708 |
}
|
709 |
|
710 |
.primary-btn:hover {
|
711 |
+
[cite_start]transform: translateY(-2px) !important; [cite: 112]
|
712 |
box-shadow:
|
713 |
0 8px 25px rgba(255, 193, 7, 0.4),
|
714 |
+
[cite_start]0 0 30px rgba(255, 193, 7, 0.3) !important; [cite: 113]
|
715 |
}
|
716 |
|
717 |
/* Enhanced Text inputs with glow */
|
718 |
.gradio-textbox input, .gradio-textbox textarea {
|
719 |
+
[cite_start]background: rgba(45, 45, 45, 0.8) !important; [cite: 114]
|
720 |
+
[cite_start]color: #ffffff !important; [cite: 114]
|
721 |
+
[cite_start]border: 2px solid rgba(255, 193, 7, 0.2) !important; [cite: 114]
|
722 |
+
[cite_start]border-radius: 12px !important; [cite: 114]
|
723 |
+
[cite_start]font-size: 0.95rem !important; [cite: 115]
|
724 |
+
[cite_start]padding: 0.75rem 1rem !important; [cite: 115]
|
725 |
+
[cite_start]transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important; [cite: 115]
|
726 |
+
[cite_start]backdrop-filter: blur(10px) !important; [cite: 116]
|
727 |
+
[cite_start]box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important; [cite: 117]
|
728 |
}
|
729 |
|
730 |
.gradio-textbox input:focus, .gradio-textbox textarea:focus {
|
731 |
+
[cite_start]border-color: rgba(255, 193, 7, 0.5) !important; [cite: 118]
|
732 |
box-shadow:
|
733 |
0 0 20px rgba(255, 193, 7, 0.2),
|
734 |
+
[cite_start]inset 0 2px 4px rgba(0, 0, 0, 0.1) !important; [cite: 119]
|
735 |
+
[cite_start]outline: none !important; [cite: 119]
|
736 |
}
|
737 |
|
738 |
/* Enhanced Processing indicator */
|
739 |
.processing-indicator {
|
740 |
+
[cite_start]background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.08)); [cite: 120]
|
741 |
+
[cite_start]border: 2px solid rgba(255, 193, 7, 0.3); [cite: 120]
|
742 |
+
[cite_start]border-radius: 12px; [cite: 120]
|
743 |
+
[cite_start]padding: 1rem 1.5rem; [cite: 120]
|
744 |
+
[cite_start]margin: 1rem 0; [cite: 120]
|
745 |
+
[cite_start]color: #ffc107; [cite: 120]
|
746 |
+
[cite_start]text-align: center; [cite: 121]
|
747 |
+
[cite_start]font-weight: 500; [cite: 121]
|
748 |
+
[cite_start]backdrop-filter: blur(10px); [cite: 121]
|
749 |
box-shadow:
|
750 |
0 0 25px rgba(255, 193, 7, 0.1),
|
751 |
+
[cite_start]inset 0 1px 0 rgba(255, 255, 255, 0.1); [cite: 122]
|
752 |
+
[cite_start]animation: processingPulse 2s ease-in-out infinite; [cite: 122]
|
753 |
}
|
754 |
|
755 |
@keyframes processingPulse {
|
756 |
+
[cite_start]0%, 100% { opacity: 1; [cite: 123] }
|
757 |
+
[cite_start]50% { opacity: 0.8; [cite: 124] }
|
758 |
}
|
759 |
|
760 |
/* Enhanced Input row styling */
|
761 |
.input-row {
|
762 |
+
[cite_start]display: flex !important; [cite: 125]
|
763 |
+
[cite_start]gap: 12px !important; [cite: 125]
|
764 |
+
[cite_start]align-items: end !important; [cite: 125]
|
765 |
}
|
766 |
|
767 |
/* Message input */
|
768 |
.message-input {
|
769 |
+
[cite_start]flex: 1 !important; [cite: 126]
|
770 |
+
[cite_start]min-height: 48px !important; [cite: 126]
|
771 |
}
|
772 |
|
773 |
/* Markdown content styling - applies to text within gr.Markdown components */
|
774 |
.markdown-content {
|
775 |
+
color: #ffffff !important; [cite_start]/* UPDATED from #e0e0e0 */ [cite: 127]
|
776 |
+
[cite_start]line-height: 1.6 !important; [cite: 128]
|
777 |
+
[cite_start]font-size: 0.95rem !important; [cite: 128]
|
778 |
}
|
779 |
|
780 |
.markdown-content h1, .markdown-content h2, .markdown-content h3 {
|
781 |
+
[cite_start]color: #ffc107 !important; [cite: 129]
|
782 |
+
[cite_start]margin-top: 1.5rem !important; [cite: 129]
|
783 |
+
[cite_start]margin-bottom: 0.5rem !important; [cite: 129]
|
784 |
}
|
785 |
|
786 |
.markdown-content code {
|
787 |
+
[cite_start]background: rgba(255, 193, 7, 0.1) !important; [cite: 130]
|
788 |
+
[cite_start]color: #ffc107 !important; [cite: 130]
|
789 |
+
[cite_start]padding: 0.2rem 0.4rem !important; [cite: 130]
|
790 |
+
[cite_start]border-radius: 4px !important; [cite: 131]
|
791 |
}
|
792 |
|
793 |
.markdown-content pre {
|
794 |
+
[cite_start]background: rgba(0, 0, 0, 0.3) !important; [cite: 132]
|
795 |
+
[cite_start]border: 1px solid rgba(255, 193, 7, 0.2) !important; [cite: 132]
|
796 |
+
[cite_start]border-radius: 8px !important; [cite: 132]
|
797 |
+
[cite_start]padding: 1rem !important; [cite: 132]
|
798 |
+
[cite_start]margin: 1rem 0 !important; [cite: 133]
|
799 |
}
|
800 |
|
801 |
/* Examples styling */
|
802 |
.examples {
|
803 |
+
[cite_start]background: rgba(45, 45, 45, 0.3) !important; [cite: 134]
|
804 |
+
[cite_start]border-radius: 12px !important; [cite: 134]
|
805 |
+
[cite_start]padding: 1rem !important; [cite: 134]
|
806 |
+
[cite_start]border: 1px solid rgba(255, 193, 7, 0.1) !important; [cite: 134]
|
807 |
+
[cite_start]backdrop-filter: blur(10px) !important; [cite: 134]
|
808 |
+
color: #ffffff !important; [cite_start]/* UPDATED from #e0e0e0 */ [cite: 135]
|
809 |
}
|
810 |
|
811 |
/* General paragraph text and Gradio HTML components (for architecture text) */
|
812 |
.gradio-container p,
|
813 |
.gradio-container .gr-html {
|
814 |
+
color: #ffffff !important; [cite_start]/* UPDATED from #e0e0e0 */ [cite: 136]
|
815 |
}
|
816 |
|
817 |
/* Loading animation */
|
818 |
@keyframes loading {
|
819 |
+
[cite_start]0% { transform: rotate(0deg); [cite: 137] }
|
820 |
+
[cite_start]100% { transform: rotate(360deg); [cite: 138] }
|
821 |
}
|
822 |
|
823 |
.loading {
|
824 |
+
[cite_start]animation: loading 2s linear infinite; [cite: 139]
|
825 |
}
|
826 |
|
827 |
/* Responsive design */
|
|
|
834 |
with gr.Column():
|
835 |
gr.HTML("""
|
836 |
<div class="header">
|
837 |
+
[cite_start]<h1> Agentic RAG Assistant</h1> [cite: 140]
|
838 |
<p>Upload documents and ask questions - powered by Multi-Agent Architecture with streaming responses</p>
|
839 |
</div>
|
840 |
""")
|
841 |
|
842 |
# Main layout with sidebar and chat
|
843 |
+
[cite_start]with gr.Row(): [cite: 141]
|
844 |
# Left sidebar for file upload
|
845 |
with gr.Column(scale=1, elem_classes=["sidebar"]):
|
846 |
+
gr.Markdown("### 刀 Document Upload", elem_classes=["markdown-content"])
|
847 |
|
848 |
file_upload = gr.File(
|
849 |
+
[cite_start]file_count="multiple", [cite: 142]
|
850 |
+
[cite_start]file_types=[".pdf", ".pptx", ".csv", ".docx", ".txt", ".md"], [cite: 142]
|
851 |
+
[cite_start]label="塘 Upload Documents", [cite: 142]
|
852 |
+
[cite_start]elem_classes=["upload-area"] [cite: 142]
|
853 |
)
|
854 |
|
855 |
+
[cite_start]processing_status = gr.HTML(visible=False) [cite: 143]
|
856 |
|
857 |
process_btn = gr.Button(
|
858 |
" Process Documents",
|
859 |
variant="primary",
|
860 |
+
[cite_start]elem_classes=["primary-btn"] [cite: 144]
|
861 |
)
|
862 |
|
863 |
+
# REMOVED the Architecture Markdown block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
864 |
|
865 |
# Right side - Chat interface
|
866 |
with gr.Column(scale=2):
|
867 |
+
gr.Markdown("### 町 Chat Interface", elem_classes=["markdown-content"])
|
868 |
|
869 |
# Chatbot with enhanced styling
|
870 |
+
[cite_start]chatbot = gr.Chatbot( [cite: 148]
|
871 |
+
[cite_start]height=400, [cite: 148]
|
872 |
+
[cite_start]elem_classes=["gradio-chatbot"], [cite: 148]
|
873 |
+
[cite_start]show_copy_button=True, [cite: 148]
|
874 |
+
[cite_start]type="messages", [cite: 149]
|
875 |
+
[cite_start]placeholder="Upload documents , then start chatting! Ask me anything about your documents.", [cite: 149, 150]
|
876 |
+
[cite_start]avatar_images=("側", "、) [cite: 150]
|
877 |
)
|
878 |
|
879 |
# Input area with improved layout
|
880 |
with gr.Row(elem_classes=["input-row"]):
|
881 |
+
[cite_start]msg_input = gr.Textbox( [cite: 151]
|
882 |
+
[cite_start]placeholder="Ask about your documents...", [cite: 151]
|
883 |
+
[cite_start]label="Message", [cite: 151]
|
884 |
+
[cite_start]scale=4, [cite: 151]
|
885 |
+
[cite_start]elem_classes=["message-input"], [cite: 152]
|
886 |
+
[cite_start]show_label=False, [cite: 152]
|
887 |
+
[cite_start]autofocus=True [cite: 152]
|
888 |
)
|
889 |
+
[cite_start]send_btn = gr.Button( [cite: 153]
|
890 |
" Send",
|
891 |
scale=1,
|
892 |
+
[cite_start]elem_classes=["send-btn"], [cite: 153]
|
893 |
+
[cite_start]size="sm" [cite: 154]
|
894 |
)
|
895 |
|
896 |
+
# Enhanced Examples - UPDATED with fewer examples
|
897 |
gr.Examples(
|
898 |
examples=[
|
899 |
+
[cite_start]"Summarize the key findings", [cite: 155]
|
900 |
+
[cite_start]"What are the main topics discussed?", [cite: 155]
|
|
|
|
|
|
|
|
|
901 |
],
|
902 |
+
[cite_start]inputs=msg_input, [cite: 156]
|
903 |
+
[cite_start]label=" Example Questions", [cite: 157]
|
904 |
+
elem_classes=["examples"]
|
905 |
)
|
906 |
|
907 |
# State to track document processing
|
908 |
doc_processed = gr.State(False)
|
909 |
|
910 |
# Event handlers
|
911 |
+
[cite_start]def handle_file_upload_and_process(files): [cite: 158]
|
912 |
if not files:
|
913 |
return gr.update(visible=False), False
|
914 |
|
915 |
# Show processing indicator
|
916 |
processing_html = f"""
|
917 |
<div class="processing-indicator">
|
918 |
+
[cite_start]Processing {len(files)} documents... Please wait while we analyze your content. [cite: 159]
|
919 |
</div>
|
920 |
"""
|
921 |
|
|
|
924 |
result = coordinator_agent.process_files(files)
|
925 |
|
926 |
# Wait a moment for processing to complete
|
927 |
+
[cite_start]import time [cite: 161]
|
928 |
+
[cite_start]time.sleep(3) [cite: 161]
|
929 |
|
930 |
success_html = """
|
931 |
<div style="background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.08));
|
|
|
934 |
box-shadow: 0 0 20px rgba(76, 175, 80, 0.1);">
|
935 |
Documents processed successfully! You can now ask questions about your content.
|
936 |
</div>
|
937 |
+
[cite_start]""" [cite: 162, 163, 164]
|
938 |
return gr.update(value=success_html, visible=True), True
|
939 |
|
940 |
except Exception as e:
|
|
|
945 |
box-shadow: 0 0 20px rgba(244, 67, 54, 0.1);">
|
946 |
Error processing documents: {str(e)}
|
947 |
</div>
|
948 |
+
[cite_start]""" [cite: 165, 166]
|
949 |
return gr.update(value=error_html, visible=True), False
|
950 |
|
951 |
+
[cite_start]def respond(message, history, doc_ready): [cite: 167]
|
952 |
if not doc_ready:
|
953 |
# Show error message
|
954 |
history.append({"role": "user", "content": message})
|
955 |
history.append({"role": "assistant", "content": " Please upload and process documents first before asking questions."})
|
956 |
+
[cite_start]return history, "" [cite: 168]
|
957 |
|
958 |
if not message.strip():
|
959 |
return history, message
|
960 |
|
961 |
# Add user message
|
962 |
history.append({"role": "user", "content": message})
|
963 |
+
[cite_start]history.append({"role": "assistant", "content": ""}) [cite: 169]
|
964 |
|
965 |
# Stream response
|
966 |
try:
|
967 |
for token in coordinator_agent.handle_query(message, history):
|
968 |
history[-1]["content"] += token
|
969 |
+
[cite_start]yield history, "" [cite: 170]
|
970 |
except Exception as e:
|
971 |
history[-1]["content"] = f" Error generating response: {str(e)}"
|
972 |
yield history, ""
|
|
|
974 |
# Event bindings
|
975 |
process_btn.click(
|
976 |
handle_file_upload_and_process,
|
977 |
+
[cite_start]inputs=[file_upload], [cite: 171]
|
978 |
+
[cite_start]outputs=[processing_status, doc_processed] [cite: 171]
|
979 |
)
|
980 |
|
981 |
send_btn.click(
|
|
|
985 |
show_progress=True
|
986 |
)
|
987 |
|
988 |
+
[cite_start]msg_input.submit( [cite: 172]
|
989 |
respond,
|
990 |
inputs=[msg_input, chatbot, doc_processed],
|
991 |
outputs=[chatbot, msg_input],
|
|
|
993 |
)
|
994 |
|
995 |
return iface
|
996 |
+
|
997 |
# Launch the application
|
998 |
if __name__ == "__main__":
|
999 |
demo = create_interface()
|