ragunath-ravi commited on
Commit
027da10
Β·
verified Β·
1 Parent(s): 432cda5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +203 -464
app.py CHANGED
@@ -419,413 +419,144 @@ llm_response_agent = LLMResponseAgent(message_bus)
419
  coordinator_agent = CoordinatorAgent(message_bus)
420
 
421
  def create_interface():
422
- """Create enhanced ChatGPT-style Gradio interface with glowing effects"""
423
 
424
  with gr.Blocks(
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 {
538
- 0% {
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 {
610
- 0% {
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 */
828
- """,
829
  title="Agentic RAG Assistant"
830
  ) as iface:
831
 
@@ -834,88 +565,100 @@ def create_interface():
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
- avatar_images=("側", "`")
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,58 +667,54 @@ def create_interface():
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));
932
- border: 2px solid rgba(76, 175, 80, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
933
- color: #4caf50; text-align: center; backdrop-filter: blur(10px);
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:
941
  error_html = f"""
942
- <div style="background: linear-gradient(135deg, rgba(244, 67, 54, 0.15), rgba(244, 67, 54, 0.08));
943
- border: 2px solid rgba(244, 67, 54, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
944
- color: #f44336; text-align: center; backdrop-filter: blur(10px);
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, ""
973
 
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,7 +724,7 @@ def create_interface():
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,7 +732,7 @@ def create_interface():
993
  )
994
 
995
  return iface
996
-
997
  # Launch the application
998
  if __name__ == "__main__":
999
  demo = create_interface()
 
419
  coordinator_agent = CoordinatorAgent(message_bus)
420
 
421
  def create_interface():
422
+ """Create ChatGPT-style Gradio interface"""
423
 
424
  with gr.Blocks(
425
  theme=gr.themes.Base(),
426
  css="""
427
+ /* Dark theme styling */
428
+ .gradio-container {
429
+ background-color: #1a1a1a !important;
430
+ color: #ffffff !important;
431
+ height: 100vh !important;
432
+ max-width: none !important;
433
+ padding: 0 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  }
435
+
436
+ /* Main container */
437
+ .main-container {
438
+ display: flex;
439
+ flex-direction: column;
440
+ height: 100vh;
441
+ background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
442
  }
443
+
444
+ /* Header */
445
+ .header {
446
+ background: rgba(255, 193, 7, 0.1);
447
+ border-bottom: 1px solid rgba(255, 193, 7, 0.2);
448
+ padding: 1rem 2rem;
449
+ backdrop-filter: blur(10px);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  }
451
+
452
+ .header h1 {
453
+ color: #ffc107;
454
+ margin: 0;
455
+ font-size: 1.5rem;
456
+ font-weight: 600;
457
  }
458
+
459
+ .header p {
460
+ color: #cccccc;
461
+ margin: 0.25rem 0 0 0;
462
+ font-size: 0.9rem;
463
+ }
464
+
465
+ /* Chat area - REDUCED HEIGHT */
466
+ .chat-container {
467
+ flex: 1;
468
+ display: flex;
469
+ flex-direction: column;
470
+ max-width: 1000px;
471
+ margin: 0 auto;
472
+ width: 100%;
473
+ padding: 1rem;
474
+ height: calc(100vh - 200px) !important; /* Reduced height */
475
+ }
476
+
477
+ /* Chatbot styling - SMALLER */
478
+ .gradio-chatbot {
479
+ height: 300px !important; /* Reduced from 500px */
480
+ max-height: 300px !important;
481
+ background: transparent !important;
482
+ border: none !important;
483
+ margin-bottom: 1rem;
484
+ overflow-y: auto !important;
485
+ box-shadow: 0 0 12px rgba(255, 193, 7, 0.1);
486
+
487
+ }
488
+
489
+ /* Input area */
490
+ .input-area {
491
+ background: rgba(45, 45, 45, 0.6);
492
+ border-radius: 16px;
493
+ padding: 1rem;
494
+ border: 1px solid rgba(255, 193, 7, 0.2);
495
+ backdrop-filter: blur(10px);
496
+ position: sticky;
497
+ bottom: 0;
498
+ }
499
+
500
+ /* File upload */
501
+ .upload-area {
502
+ background: rgba(255, 193, 7, 0.05);
503
+ border: 2px dashed rgba(255, 193, 7, 0.3);
504
+ border-radius: 12px;
505
+ padding: 1rem;
506
+ margin-bottom: 1rem;
507
+ transition: all 0.3s ease;
508
+ }
509
+
510
+ /* Buttons - YELLOW SEND BUTTON */
511
+ .send-btn {
512
+ background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important;
513
+ color: #000000 !important;
514
+ border: none !important;
515
+ border-radius: 8px !important;
516
+ font-weight: 600 !important;
517
+ min-height: 40px !important;
518
+ }
519
+
520
+ .primary-btn {
521
+ background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important;
522
+ color: #000000 !important;
523
+ border: none !important;
524
+ border-radius: 8px !important;
525
+ font-weight: 600 !important;
526
+ }
527
+
528
+ /* Text inputs */
529
+ .gradio-textbox input, .gradio-textbox textarea {
530
+ background: rgba(45, 45, 45, 0.8) !important;
531
+ color: #ffffff !important;
532
+ border: 1px solid rgba(255, 193, 7, 0.2) !important;
533
+ border-radius: 8px !important;
534
+ }
535
+
536
+ /* Processing indicator */
537
+ .processing-indicator {
538
+ background: rgba(255, 193, 7, 0.1);
539
+ border: 1px solid rgba(255, 193, 7, 0.3);
540
+ border-radius: 8px;
541
+ padding: 0.75rem;
542
+ margin: 0.5rem 0;
543
+ color: #ffc107;
544
+ text-align: center;
545
+ }
546
+
547
+ /* Input row styling */
548
+ .input-row {
549
+ display: flex !important;
550
+ gap: 10px !important;
551
+ align-items: end !important;
552
+ }
553
+
554
+ /* Message input */
555
+ .message-input {
556
+ flex: 1 !important;
557
+ min-height: 40px !important;
558
+ }
559
+ """,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
  title="Agentic RAG Assistant"
561
  ) as iface:
562
 
 
565
  with gr.Column():
566
  gr.HTML("""
567
  <div class="header">
568
+ <h1>Agentic RAG Assistant</h1>
569
+ <p>Upload documents and ask questions - powered by Multi-Agent Architecture</p>
570
  </div>
571
  """)
572
 
573
  # Main layout with sidebar and chat
574
+ with gr.Row():
575
  # Left sidebar for file upload
576
+ with gr.Column(scale=1):
577
+ gr.Markdown("### πŸ“ Document Upload")
578
 
579
  file_upload = gr.File(
580
+ file_count="multiple",
581
+ file_types=[".pdf", ".pptx", ".csv", ".docx", ".txt", ".md"],
582
+ label="Upload Documents",
583
+ elem_classes=["upload-area"]
584
  )
585
 
586
+ processing_status = gr.HTML(visible=False)
587
 
588
  process_btn = gr.Button(
589
+ "Process Documents",
590
  variant="primary",
591
+ elem_classes=["primary-btn"]
592
  )
593
 
594
+ # gr.Markdown("### ℹ️ Architecture")
595
+ # gr.Markdown("""
596
+ # **Multi-Agent System:**
597
+ # - πŸ“„ **IngestionAgent**: Document parsing
598
+ # - πŸ” **RetrievalAgent**: Semantic search
599
+ # - πŸ€– **LLMAgent**: Response generation
600
+ # - 🎯 **CoordinatorAgent**: Workflow orchestration
601
+
602
+ # **Features:**
603
+ # - Streaming responses
604
+ # - Multi-format support
605
+ # - Context-aware answers
606
+ # """)
607
 
608
  # Right side - Chat interface
609
  with gr.Column(scale=2):
610
+ gr.Markdown("### πŸ’¬ Chat Interface")
611
 
612
+ # Chatbot with reduced height
613
+ chatbot = gr.Chatbot(
614
+ height=300, # Reduced height
615
+ elem_classes=["gradio-chatbot"],
616
+ show_copy_button=True,
617
+ type="messages",
618
+ placeholder="Upload documents first, then start chatting!"
 
619
  )
620
 
621
  # Input area with improved layout
622
  with gr.Row(elem_classes=["input-row"]):
623
+ msg_input = gr.Textbox(
624
+ placeholder="Ask about your documents...",
625
+ label="Message",
626
+ scale=4,
627
+ elem_classes=["message-input"],
628
+ show_label=False,
629
+ autofocus=True
630
  )
631
+ send_btn = gr.Button(
632
+ "Send",
633
  scale=1,
634
+ elem_classes=["send-btn"],
635
+ size="sm"
636
  )
637
 
638
+ # Examples
639
  gr.Examples(
640
  examples=[
641
+ "What are the main topics discussed?",
642
+ "Summarize the key findings",
643
+ "What metrics are mentioned?",
644
+ "What are the recommendations?"
645
  ],
646
+ inputs=msg_input,
647
+ label="Example Questions"
 
648
  )
649
 
650
  # State to track document processing
651
  doc_processed = gr.State(False)
652
 
653
  # Event handlers
654
+ def handle_file_upload_and_process(files):
655
  if not files:
656
  return gr.update(visible=False), False
657
 
658
  # Show processing indicator
659
  processing_html = f"""
660
  <div class="processing-indicator">
661
+ πŸ“„ Processing {len(files)} documents... Please wait.
662
  </div>
663
  """
664
 
 
667
  result = coordinator_agent.process_files(files)
668
 
669
  # Wait a moment for processing to complete
670
+ import time
671
+ time.sleep(3)
672
 
673
  success_html = """
674
+ <div style="background: rgba(76, 175, 80, 0.1); border: 1px solid rgba(76, 175, 80, 0.3);
675
+ border-radius: 8px; padding: 0.75rem; color: #4caf50; text-align: center;">
676
+ Documents processed successfully! You can now ask questions.
 
 
677
  </div>
678
+ """
679
  return gr.update(value=success_html, visible=True), True
680
 
681
  except Exception as e:
682
  error_html = f"""
683
+ <div style="background: rgba(244, 67, 54, 0.1); border: 1px solid rgba(244, 67, 54, 0.3);
684
+ border-radius: 8px; padding: 0.75rem; color: #f44336; text-align: center;">
685
+ ❌ Error processing documents: {str(e)}
 
 
686
  </div>
687
+ """
688
  return gr.update(value=error_html, visible=True), False
689
 
690
+ def respond(message, history, doc_ready):
691
  if not doc_ready:
692
  # Show error message
693
  history.append({"role": "user", "content": message})
694
+ history.append({"role": "assistant", "content": " Please upload and process documents first."})
695
+ return history, ""
696
 
697
  if not message.strip():
698
  return history, message
699
 
700
  # Add user message
701
  history.append({"role": "user", "content": message})
702
+ history.append({"role": "assistant", "content": ""})
703
 
704
  # Stream response
705
  try:
706
  for token in coordinator_agent.handle_query(message, history):
707
  history[-1]["content"] += token
708
+ yield history, ""
709
  except Exception as e:
710
+ history[-1]["content"] = f"❌ Error: {str(e)}"
711
  yield history, ""
712
 
713
  # Event bindings
714
  process_btn.click(
715
  handle_file_upload_and_process,
716
+ inputs=[file_upload],
717
+ outputs=[processing_status, doc_processed]
718
  )
719
 
720
  send_btn.click(
 
724
  show_progress=True
725
  )
726
 
727
+ msg_input.submit(
728
  respond,
729
  inputs=[msg_input, chatbot, doc_processed],
730
  outputs=[chatbot, msg_input],
 
732
  )
733
 
734
  return iface
735
+
736
  # Launch the application
737
  if __name__ == "__main__":
738
  demo = create_interface()