ragunath-ravi commited on
Commit
9994ccc
Β·
verified Β·
1 Parent(s): 0be599b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +428 -356
app.py CHANGED
@@ -419,455 +419,520 @@ llm_response_agent = LLMResponseAgent(message_bus)
419
  coordinator_agent = CoordinatorAgent(message_bus)
420
 
421
  def create_interface():
422
- """Create enhanced Gradio interface with improved UI"""
423
 
424
  with gr.Blocks(
425
- theme=gr.themes.Soft(),
426
  css="""
427
- /* Global styling */
 
 
 
428
  .gradio-container {
429
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
430
- min-height: 100vh;
431
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  }
433
 
434
- /* Main container */
435
- .main-wrapper {
436
- background: rgba(255, 255, 255, 0.05);
 
 
 
437
  backdrop-filter: blur(20px);
438
- border: 1px solid rgba(255, 255, 255, 0.1);
439
- border-radius: 24px;
440
- margin: 20px;
441
- padding: 0;
442
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
443
  overflow: hidden;
444
  }
445
 
446
- /* Header section */
447
- .app-header {
448
- background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
449
- padding: 24px 32px;
450
- border-bottom: 1px solid rgba(255, 255, 255, 0.1);
451
- text-align: center;
 
 
 
 
 
 
 
 
452
  }
453
 
454
- .app-title {
455
- font-size: 32px;
 
 
456
  font-weight: 700;
457
- background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
458
- -webkit-background-clip: text;
459
- -webkit-text-fill-color: transparent;
460
- background-clip: text;
461
- margin: 0 0 8px 0;
462
  letter-spacing: -0.02em;
463
  }
464
 
465
- .app-subtitle {
466
- color: rgba(255, 255, 255, 0.7);
467
- font-size: 16px;
 
468
  font-weight: 400;
469
- margin: 0;
470
- line-height: 1.5;
471
  }
472
 
473
- /* Content area */
474
- .content-area {
475
- padding: 32px;
476
  display: flex;
477
- gap: 32px;
478
- min-height: 600px;
 
 
 
 
 
479
  }
480
 
481
- /* Sidebar */
482
- .sidebar {
483
- flex: 0 0 320px;
484
- background: rgba(255, 255, 255, 0.08);
485
- border-radius: 16px;
486
- padding: 24px;
487
- border: 1px solid rgba(255, 255, 255, 0.1);
488
- height: fit-content;
489
- }
490
-
491
- .sidebar-title {
492
- color: white;
493
- font-size: 18px;
494
- font-weight: 600;
495
- margin: 0 0 20px 0;
496
- padding-bottom: 12px;
497
- border-bottom: 1px solid rgba(255, 255, 255, 0.1);
498
- }
499
-
500
- /* File upload area */
501
- .upload-container {
502
- background: rgba(255, 255, 255, 0.05);
503
- border: 2px dashed rgba(255, 255, 255, 0.2);
504
- border-radius: 12px;
505
- padding: 24px;
506
- text-align: center;
507
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
508
- margin-bottom: 20px;
509
- cursor: pointer;
510
  }
511
 
512
- .upload-container:hover {
513
- background: rgba(255, 255, 255, 0.08);
514
- border-color: rgba(255, 255, 255, 0.3);
515
- transform: translateY(-2px);
 
 
 
 
 
 
 
 
 
516
  }
517
 
518
- .upload-text {
519
- color: rgba(255, 255, 255, 0.8);
520
- font-size: 14px;
521
- margin: 8px 0;
 
 
 
 
 
 
 
 
522
  }
523
 
524
- /* Buttons */
525
- .primary-button {
526
- background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
527
- color: white;
528
- border: none;
529
- border-radius: 12px;
530
- padding: 12px 24px;
531
- font-weight: 600;
532
- font-size: 14px;
533
- cursor: pointer;
534
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
535
- box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.25);
536
- width: 100%;
537
  }
538
 
539
- .primary-button:hover {
540
- transform: translateY(-2px);
541
- box-shadow: 0 8px 25px 0 rgba(59, 130, 246, 0.35);
 
 
 
 
 
542
  }
543
 
544
- .send-button {
545
- background: linear-gradient(135deg, #10b981 0%, #059669 100%);
546
- color: white;
547
- border: none;
548
- border-radius: 8px;
549
- padding: 10px 20px;
550
- font-weight: 600;
551
- font-size: 14px;
552
- cursor: pointer;
553
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
554
- box-shadow: 0 2px 8px 0 rgba(16, 185, 129, 0.25);
555
- min-width: 80px;
556
  }
557
 
558
- .send-button:hover {
559
- transform: translateY(-1px);
560
- box-shadow: 0 4px 12px 0 rgba(16, 185, 129, 0.35);
 
 
 
 
 
 
 
 
 
 
 
561
  }
562
 
563
- /* Chat area */
564
- .chat-section {
565
- flex: 1;
566
- display: flex;
567
- flex-direction: column;
568
- background: rgba(255, 255, 255, 0.05);
569
- border-radius: 16px;
570
- border: 1px solid rgba(255, 255, 255, 0.1);
571
- overflow: hidden;
 
 
 
 
572
  }
573
 
574
- .chat-header {
575
- padding: 20px 24px;
576
- background: rgba(255, 255, 255, 0.05);
577
- border-bottom: 1px solid rgba(255, 255, 255, 0.1);
 
 
 
 
 
 
 
 
578
  }
579
 
580
- .chat-title {
581
- color: white;
582
- font-size: 18px;
583
- font-weight: 600;
584
- margin: 0;
 
 
585
  }
586
 
587
- /* Chatbot styling */
588
- .gradio-chatbot {
589
- background: transparent !important;
 
 
 
 
 
 
 
 
 
 
 
590
  border: none !important;
591
- height: 400px !important;
592
- max-height: 400px !important;
593
- padding: 20px 24px !important;
594
- overflow-y: auto !important;
 
 
 
 
 
 
595
  }
596
 
597
- /* Message bubbles */
598
- .message.user {
599
- background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
600
- color: white;
601
- border-radius: 18px 18px 4px 18px;
602
- margin: 8px 0 8px 48px;
603
- padding: 12px 16px;
604
- max-width: 80%;
605
- margin-left: auto;
606
- box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
607
- }
608
-
609
- .message.bot {
610
- background: rgba(255, 255, 255, 0.1);
611
- color: white;
612
- border: 1px solid rgba(255, 255, 255, 0.1);
613
- border-radius: 18px 18px 18px 4px;
614
- margin: 8px 48px 8px 0;
615
- padding: 12px 16px;
616
- max-width: 80%;
617
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
618
- }
619
-
620
- /* Input area */
621
- .input-section {
622
- padding: 20px 24px;
623
- background: rgba(255, 255, 255, 0.05);
624
- border-top: 1px solid rgba(255, 255, 255, 0.1);
625
  }
626
 
627
- .input-row {
628
- display: flex !important;
629
- gap: 12px !important;
630
- align-items: end !important;
631
  }
632
 
633
- .message-input {
634
- flex: 1 !important;
635
- background: rgba(255, 255, 255, 0.1) !important;
636
- border: 1px solid rgba(255, 255, 255, 0.2) !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637
  border-radius: 12px !important;
638
- padding: 12px 16px !important;
639
- color: white !important;
640
- font-size: 14px !important;
641
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
 
 
642
  }
643
 
644
- .message-input:focus {
645
- background: rgba(255, 255, 255, 0.15) !important;
646
- border-color: rgba(255, 255, 255, 0.4) !important;
647
- box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1) !important;
 
648
  outline: none !important;
649
  }
650
 
651
- /* Status indicators */
652
- .status-indicator {
 
 
653
  border-radius: 12px;
654
- padding: 16px;
655
- margin: 16px 0;
656
- font-size: 14px;
657
- font-weight: 500;
658
  text-align: center;
 
659
  backdrop-filter: blur(10px);
 
 
 
 
660
  }
661
 
662
- .status-success {
663
- background: rgba(16, 185, 129, 0.15);
664
- color: #10b981;
665
- border: 1px solid rgba(16, 185, 129, 0.3);
666
- }
667
-
668
- .status-error {
669
- background: rgba(239, 68, 68, 0.15);
670
- color: #ef4444;
671
- border: 1px solid rgba(239, 68, 68, 0.3);
672
  }
673
 
674
- .status-processing {
675
- background: rgba(59, 130, 246, 0.15);
676
- color: #3b82f6;
677
- border: 1px solid rgba(59, 130, 246, 0.3);
 
678
  }
679
 
680
- /* Examples section */
681
- .examples-container {
682
- margin-top: 16px;
 
683
  }
684
 
685
- .examples-title {
686
- color: rgba(255, 255, 255, 0.8);
687
- font-size: 14px;
688
- font-weight: 500;
689
- margin-bottom: 12px;
690
  }
691
 
692
- .example-item {
693
- background: rgba(255, 255, 255, 0.05);
694
- border: 1px solid rgba(255, 255, 255, 0.1);
695
- border-radius: 8px;
696
- padding: 8px 12px;
697
- color: rgba(255, 255, 255, 0.8);
698
- font-size: 13px;
699
- cursor: pointer;
700
- transition: all 0.2s ease;
701
- margin-bottom: 6px;
702
  }
703
 
704
- .example-item:hover {
705
- background: rgba(255, 255, 255, 0.1);
706
- border-color: rgba(255, 255, 255, 0.2);
707
- color: white;
 
708
  }
709
 
710
- /* Scrollbar styling */
711
- ::-webkit-scrollbar {
712
- width: 6px;
713
- height: 6px;
 
 
714
  }
715
 
716
- ::-webkit-scrollbar-track {
717
- background: rgba(255, 255, 255, 0.1);
718
- border-radius: 3px;
 
 
 
 
719
  }
720
 
721
- ::-webkit-scrollbar-thumb {
722
- background: rgba(255, 255, 255, 0.3);
723
- border-radius: 3px;
 
724
  }
725
 
726
- ::-webkit-scrollbar-thumb:hover {
727
- background: rgba(255, 255, 255, 0.5);
728
  }
729
 
730
  /* Responsive design */
731
  @media (max-width: 768px) {
732
- .content-area {
733
- flex-direction: column;
734
- padding: 16px;
735
- gap: 16px;
736
  }
737
 
738
- .sidebar {
739
- flex: none;
740
  }
741
 
742
- .main-wrapper {
743
- margin: 10px;
744
  }
745
 
746
- .app-title {
747
- font-size: 24px;
 
748
  }
749
  }
750
-
751
- /* Form elements */
752
- .gradio-textbox input, .gradio-textbox textarea {
753
- background: rgba(255, 255, 255, 0.1) !important;
754
- color: white !important;
755
- border: 1px solid rgba(255, 255, 255, 0.2) !important;
756
- border-radius: 8px !important;
757
- }
758
-
759
- .gradio-textbox input:focus, .gradio-textbox textarea:focus {
760
- border-color: rgba(255, 255, 255, 0.4) !important;
761
- box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1) !important;
762
- }
763
-
764
- /* File upload specific styling */
765
- .gradio-file {
766
- background: transparent !important;
767
- border: none !important;
768
- }
769
-
770
- .gradio-file .file-preview {
771
- background: rgba(255, 255, 255, 0.05) !important;
772
- border: 1px solid rgba(255, 255, 255, 0.1) !important;
773
- border-radius: 8px !important;
774
- color: white !important;
775
- }
776
  """,
777
  title="Agentic RAG Assistant"
778
  ) as iface:
779
 
780
- # Main wrapper
781
- with gr.Column(elem_classes=["main-wrapper"]):
782
-
783
- # Header
784
- gr.HTML("""
785
- <div class="app-header">
786
- <h1 class="app-title">Agentic RAG Assistant</h1>
787
- <p class="app-subtitle">Upload documents and ask questions - powered by Multi-Agent Architecture</p>
788
- </div>
789
- """)
790
 
791
- # Content area
792
- with gr.Row(elem_classes=["content-area"]):
 
 
 
793
 
794
- # Sidebar
795
- with gr.Column(elem_classes=["sidebar"]):
796
- gr.HTML('<h3 class="sidebar-title">Document Management</h3>')
797
-
798
- gr.HTML("""
799
- <div class="upload-container">
800
- <div class="upload-text">Drag and drop files here or click to browse</div>
801
- <div style="color: rgba(255, 255, 255, 0.6); font-size: 12px; margin-top: 8px;">
802
- Supported: PDF, PPTX, CSV, DOCX, TXT, MD
803
- </div>
804
- </div>
805
- """)
806
-
807
- file_upload = gr.File(
808
- file_count="multiple",
809
- file_types=[".pdf", ".pptx", ".csv", ".docx", ".txt", ".md"],
810
- label="",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
811
  show_label=False,
812
- container=False
813
  )
814
-
815
- processing_status = gr.HTML(visible=False)
816
-
817
- process_btn = gr.Button(
818
- "Process Documents",
819
- elem_classes=["primary-button"],
820
- size="lg"
821
  )
822
 
823
- # Chat section
824
- with gr.Column(elem_classes=["chat-section"]):
825
-
826
- # Chat header
827
- gr.HTML('<div class="chat-header"><h3 class="chat-title">Conversation</h3></div>')
828
-
829
- # Chatbot
830
- chatbot = gr.Chatbot(
831
- height=400,
832
- elem_classes=["gradio-chatbot"],
833
- show_copy_button=True,
834
- type="messages",
835
- placeholder="Upload and process documents to start chatting..."
836
- )
837
-
838
- # Input section
839
- with gr.Column(elem_classes=["input-section"]):
840
- with gr.Row(elem_classes=["input-row"]):
841
- msg_input = gr.Textbox(
842
- placeholder="Type your question about the uploaded documents...",
843
- label="",
844
- show_label=False,
845
- scale=4,
846
- elem_classes=["message-input"],
847
- autofocus=True,
848
- container=False
849
- )
850
- send_btn = gr.Button(
851
- "Send",
852
- scale=1,
853
- elem_classes=["send-button"],
854
- size="sm"
855
- )
856
-
857
- # Examples
858
- with gr.Column(elem_classes=["examples-container"]):
859
- gr.HTML('<div class="examples-title">Example Questions</div>')
860
- gr.Examples(
861
- examples=[
862
- "What are the main topics discussed?",
863
- "Summarize the key findings",
864
- "What metrics are mentioned?",
865
- "What are the recommendations?"
866
- ],
867
- inputs=msg_input
868
- )
869
 
870
- # State management
871
  doc_processed = gr.State(False)
872
 
873
  # Event handlers
@@ -877,8 +942,8 @@ def create_interface():
877
 
878
  # Show processing indicator
879
  processing_html = f"""
880
- <div class="status-indicator status-processing">
881
- Processing {len(files)} documents... Please wait.
882
  </div>
883
  """
884
 
@@ -886,29 +951,36 @@ def create_interface():
886
  try:
887
  result = coordinator_agent.process_files(files)
888
 
889
- # Wait for processing
890
  import time
891
  time.sleep(3)
892
 
893
  success_html = """
894
- <div class="status-indicator status-success">
895
- Documents processed successfully! You can now ask questions.
 
 
 
896
  </div>
897
  """
898
  return gr.update(value=success_html, visible=True), True
899
 
900
  except Exception as e:
901
  error_html = f"""
902
- <div class="status-indicator status-error">
903
- Error processing documents: {str(e)}
 
 
 
904
  </div>
905
  """
906
  return gr.update(value=error_html, visible=True), False
907
 
908
  def respond(message, history, doc_ready):
909
  if not doc_ready:
 
910
  history.append({"role": "user", "content": message})
911
- history.append({"role": "assistant", "content": "Please upload and process documents first."})
912
  return history, ""
913
 
914
  if not message.strip():
@@ -924,7 +996,7 @@ def create_interface():
924
  history[-1]["content"] += token
925
  yield history, ""
926
  except Exception as e:
927
- history[-1]["content"] = f"Error: {str(e)}"
928
  yield history, ""
929
 
930
  # Event bindings
 
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
+ @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;
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 {
539
+ 0% {
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
  }
566
 
567
+ .message:hover {
568
+ transform: translateY(-1px) !important;
569
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
 
 
 
 
 
 
 
 
 
 
570
  }
571
 
572
+ /* User message styling */
573
+ .message.user {
574
+ background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 193, 7, 0.05)) !important;
575
+ border-color: rgba(255, 193, 7, 0.2) !important;
576
+ margin-left: 15% !important;
577
+ box-shadow:
578
+ 0 2px 10px rgba(255, 193, 7, 0.1),
579
+ inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
580
  }
581
 
582
+ /* Assistant message styling */
583
+ .message.assistant {
584
+ background: linear-gradient(135deg, rgba(0, 123, 255, 0.08), rgba(0, 123, 255, 0.04)) !important;
585
+ border-color: rgba(0, 123, 255, 0.2) !important;
586
+ margin-right: 15% !important;
587
+ box-shadow:
588
+ 0 2px 10px rgba(0, 123, 255, 0.1),
589
+ inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
 
 
 
 
590
  }
591
 
592
+ /* Enhanced Input area with glow */
593
+ .input-area {
594
+ background: rgba(45, 45, 45, 0.6);
595
+ border-radius: 20px;
596
+ padding: 1.5rem;
597
+ border: 2px solid rgba(255, 193, 7, 0.2);
598
+ backdrop-filter: blur(20px);
599
+ position: sticky;
600
+ bottom: 0;
601
+ box-shadow:
602
+ 0 0 25px rgba(255, 193, 7, 0.1),
603
+ 0 8px 32px rgba(0, 0, 0, 0.2),
604
+ inset 0 1px 0 rgba(255, 255, 255, 0.05);
605
+ animation: inputGlow 3s ease-in-out infinite alternate;
606
  }
607
 
608
+ @keyframes inputGlow {
609
+ 0% {
610
+ box-shadow:
611
+ 0 0 25px rgba(255, 193, 7, 0.1),
612
+ 0 8px 32px rgba(0, 0, 0, 0.2),
613
+ inset 0 1px 0 rgba(255, 255, 255, 0.05);
614
+ }
615
+ 100% {
616
+ box-shadow:
617
+ 0 0 35px rgba(255, 193, 7, 0.2),
618
+ 0 12px 40px rgba(0, 0, 0, 0.3),
619
+ inset 0 1px 0 rgba(255, 255, 255, 0.08);
620
+ }
621
  }
622
 
623
+ /* Enhanced File upload area */
624
+ .upload-area {
625
+ background: linear-gradient(135deg, rgba(255, 193, 7, 0.08), rgba(255, 193, 7, 0.04)) !important;
626
+ border: 2px dashed rgba(255, 193, 7, 0.4) !important;
627
+ border-radius: 16px !important;
628
+ padding: 1.5rem !important;
629
+ margin-bottom: 1.5rem !important;
630
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
631
+ backdrop-filter: blur(10px) !important;
632
+ box-shadow:
633
+ 0 0 20px rgba(255, 193, 7, 0.05),
634
+ inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
635
  }
636
 
637
+ .upload-area:hover {
638
+ background: linear-gradient(135deg, rgba(255, 193, 7, 0.12), rgba(255, 193, 7, 0.06)) !important;
639
+ border-color: rgba(255, 193, 7, 0.6) !important;
640
+ box-shadow:
641
+ 0 0 30px rgba(255, 193, 7, 0.15),
642
+ inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
643
+ transform: translateY(-2px) !important;
644
  }
645
 
646
+ /* Sidebar styling */
647
+ .sidebar {
648
+ background: rgba(30, 30, 30, 0.6) !important;
649
+ border-right: 2px solid rgba(255, 193, 7, 0.1) !important;
650
+ backdrop-filter: blur(15px) !important;
651
+ box-shadow:
652
+ inset -1px 0 0 rgba(255, 255, 255, 0.05),
653
+ 4px 0 20px rgba(0, 0, 0, 0.1) !important;
654
+ }
655
+
656
+ /* Enhanced buttons with glow effects */
657
+ .send-btn {
658
+ background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important;
659
+ color: #000000 !important;
660
  border: none !important;
661
+ border-radius: 12px !important;
662
+ font-weight: 600 !important;
663
+ min-height: 48px !important;
664
+ font-size: 0.95rem !important;
665
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
666
+ box-shadow:
667
+ 0 4px 15px rgba(255, 193, 7, 0.3),
668
+ 0 0 20px rgba(255, 193, 7, 0.2) !important;
669
+ position: relative;
670
+ overflow: hidden;
671
  }
672
 
673
+ .send-btn::before {
674
+ content: '';
675
+ position: absolute;
676
+ top: 0;
677
+ left: -100%;
678
+ width: 100%;
679
+ height: 100%;
680
+ background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
681
+ transition: left 0.5s;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
  }
683
 
684
+ .send-btn:hover::before {
685
+ left: 100%;
 
 
686
  }
687
 
688
+ .send-btn:hover {
689
+ transform: translateY(-2px) !important;
690
+ box-shadow:
691
+ 0 8px 25px rgba(255, 193, 7, 0.4),
692
+ 0 0 30px rgba(255, 193, 7, 0.3) !important;
693
+ }
694
+
695
+ .primary-btn {
696
+ background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%) !important;
697
+ color: #000000 !important;
698
+ border: none !important;
699
+ border-radius: 12px !important;
700
+ font-weight: 600 !important;
701
+ padding: 0.75rem 1.5rem !important;
702
+ font-size: 0.95rem !important;
703
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
704
+ box-shadow:
705
+ 0 4px 15px rgba(255, 193, 7, 0.3),
706
+ 0 0 20px rgba(255, 193, 7, 0.2) !important;
707
+ }
708
+
709
+ .primary-btn:hover {
710
+ transform: translateY(-2px) !important;
711
+ box-shadow:
712
+ 0 8px 25px rgba(255, 193, 7, 0.4),
713
+ 0 0 30px rgba(255, 193, 7, 0.3) !important;
714
+ }
715
+
716
+ /* Enhanced Text inputs with glow */
717
+ .gradio-textbox input, .gradio-textbox textarea {
718
+ background: rgba(45, 45, 45, 0.8) !important;
719
+ color: #ffffff !important;
720
+ border: 2px solid rgba(255, 193, 7, 0.2) !important;
721
  border-radius: 12px !important;
722
+ font-size: 0.95rem !important;
723
+ padding: 0.75rem 1rem !important;
 
724
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
725
+ backdrop-filter: blur(10px) !important;
726
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
727
  }
728
 
729
+ .gradio-textbox input:focus, .gradio-textbox textarea:focus {
730
+ border-color: rgba(255, 193, 7, 0.5) !important;
731
+ box-shadow:
732
+ 0 0 20px rgba(255, 193, 7, 0.2),
733
+ inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
734
  outline: none !important;
735
  }
736
 
737
+ /* Enhanced Processing indicator */
738
+ .processing-indicator {
739
+ background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.08));
740
+ border: 2px solid rgba(255, 193, 7, 0.3);
741
  border-radius: 12px;
742
+ padding: 1rem 1.5rem;
743
+ margin: 1rem 0;
744
+ color: #ffc107;
 
745
  text-align: center;
746
+ font-weight: 500;
747
  backdrop-filter: blur(10px);
748
+ box-shadow:
749
+ 0 0 25px rgba(255, 193, 7, 0.1),
750
+ inset 0 1px 0 rgba(255, 255, 255, 0.1);
751
+ animation: processingPulse 2s ease-in-out infinite;
752
  }
753
 
754
+ @keyframes processingPulse {
755
+ 0%, 100% { opacity: 1; }
756
+ 50% { opacity: 0.8; }
 
 
 
 
 
 
 
757
  }
758
 
759
+ /* Enhanced Input row styling */
760
+ .input-row {
761
+ display: flex !important;
762
+ gap: 12px !important;
763
+ align-items: end !important;
764
  }
765
 
766
+ /* Message input */
767
+ .message-input {
768
+ flex: 1 !important;
769
+ min-height: 48px !important;
770
  }
771
 
772
+ /* Markdown content styling */
773
+ .markdown-content {
774
+ color: #e0e0e0 !important;
775
+ line-height: 1.6 !important;
776
+ font-size: 0.95rem !important;
777
  }
778
 
779
+ .markdown-content h1, .markdown-content h2, .markdown-content h3 {
780
+ color: #ffc107 !important;
781
+ margin-top: 1.5rem !important;
782
+ margin-bottom: 0.5rem !important;
 
 
 
 
 
 
783
  }
784
 
785
+ .markdown-content code {
786
+ background: rgba(255, 193, 7, 0.1) !important;
787
+ color: #ffc107 !important;
788
+ padding: 0.2rem 0.4rem !important;
789
+ border-radius: 4px !important;
790
  }
791
 
792
+ .markdown-content pre {
793
+ background: rgba(0, 0, 0, 0.3) !important;
794
+ border: 1px solid rgba(255, 193, 7, 0.2) !important;
795
+ border-radius: 8px !important;
796
+ padding: 1rem !important;
797
+ margin: 1rem 0 !important;
798
  }
799
 
800
+ /* Examples styling */
801
+ .examples {
802
+ background: rgba(45, 45, 45, 0.3) !important;
803
+ border-radius: 12px !important;
804
+ padding: 1rem !important;
805
+ border: 1px solid rgba(255, 193, 7, 0.1) !important;
806
+ backdrop-filter: blur(10px) !important;
807
  }
808
 
809
+ /* Loading animation */
810
+ @keyframes loading {
811
+ 0% { transform: rotate(0deg); }
812
+ 100% { transform: rotate(360deg); }
813
  }
814
 
815
+ .loading {
816
+ animation: loading 2s linear infinite;
817
  }
818
 
819
  /* Responsive design */
820
  @media (max-width: 768px) {
821
+ .chat-container {
822
+ padding: 1rem;
 
 
823
  }
824
 
825
+ .header h1 {
826
+ font-size: 1.5rem;
827
  }
828
 
829
+ .gradio-chatbot {
830
+ height: 300px !important;
831
  }
832
 
833
+ .input-row {
834
+ flex-direction: column !important;
835
+ gap: 8px !important;
836
  }
837
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
838
  """,
839
  title="Agentic RAG Assistant"
840
  ) as iface:
841
 
842
+ # Header
843
+ with gr.Row():
844
+ with gr.Column():
845
+ gr.HTML("""
846
+ <div class="header">
847
+ <h1>✨ Agentic RAG Assistant</h1>
848
+ <p>πŸ€– Upload documents and ask questions - powered by Multi-Agent Architecture with streaming responses</p>
849
+ </div>
850
+ """)
 
851
 
852
+ # Main layout with sidebar and chat
853
+ with gr.Row():
854
+ # Left sidebar for file upload
855
+ with gr.Column(scale=1, elem_classes=["sidebar"]):
856
+ gr.Markdown("### πŸ“ Document Upload", elem_classes=["markdown-content"])
857
 
858
+ file_upload = gr.File(
859
+ file_count="multiple",
860
+ file_types=[".pdf", ".pptx", ".csv", ".docx", ".txt", ".md"],
861
+ label="πŸ“„ Upload Documents",
862
+ elem_classes=["upload-area"]
863
+ )
864
+
865
+ processing_status = gr.HTML(visible=False)
866
+
867
+ process_btn = gr.Button(
868
+ "πŸš€ Process Documents",
869
+ variant="primary",
870
+ elem_classes=["primary-btn"]
871
+ )
872
+
873
+ gr.Markdown("""
874
+ ### ⚑ Architecture
875
+
876
+ **Multi-Agent System:**
877
+ - πŸ“„ **IngestionAgent**: Document parsing
878
+ - πŸ” **RetrievalAgent**: Semantic search
879
+ - πŸ€– **LLMAgent**: Response generation
880
+ - 🎯 **CoordinatorAgent**: Workflow orchestration
881
+
882
+ **✨ Features:**
883
+ - 🌊 Streaming responses
884
+ - πŸ“š Multi-format support
885
+ - 🧠 Context-aware answers
886
+ - πŸ”₯ Real-time processing
887
+ """, elem_classes=["markdown-content"])
888
+
889
+ # Right side - Chat interface
890
+ with gr.Column(scale=2):
891
+ gr.Markdown("### πŸ’¬ Chat Interface", elem_classes=["markdown-content"])
892
+
893
+ # Chatbot with enhanced styling
894
+ chatbot = gr.Chatbot(
895
+ height=400,
896
+ elem_classes=["gradio-chatbot"],
897
+ show_copy_button=True,
898
+ type="messages",
899
+ placeholder="πŸš€ Upload documents first, then start chatting! Ask me anything about your documents.",
900
+ avatar_images=("πŸ‘€", "πŸ€–")
901
+ )
902
+
903
+ # Input area with improved layout
904
+ with gr.Row(elem_classes=["input-row"]):
905
+ msg_input = gr.Textbox(
906
+ placeholder="πŸ’­ Ask about your documents...",
907
+ label="Message",
908
+ scale=4,
909
+ elem_classes=["message-input"],
910
  show_label=False,
911
+ autofocus=True
912
  )
913
+ send_btn = gr.Button(
914
+ "πŸš€ Send",
915
+ scale=1,
916
+ elem_classes=["send-btn"],
917
+ size="sm"
 
 
918
  )
919
 
920
+ # Enhanced Examples
921
+ gr.Examples(
922
+ examples=[
923
+ "πŸ“– What are the main topics discussed?",
924
+ "πŸ“Š Summarize the key findings",
925
+ "πŸ“ˆ What metrics are mentioned?",
926
+ "πŸ’‘ What are the recommendations?",
927
+ "πŸ” Find specific information about...",
928
+ "πŸ“‹ Create a summary of the content"
929
+ ],
930
+ inputs=msg_input,
931
+ label="πŸ’‘ Example Questions",
932
+ elem_classes=["examples"]
933
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
934
 
935
+ # State to track document processing
936
  doc_processed = gr.State(False)
937
 
938
  # Event handlers
 
942
 
943
  # Show processing indicator
944
  processing_html = f"""
945
+ <div class="processing-indicator">
946
+ πŸ”„ Processing {len(files)} documents... Please wait while we analyze your content.
947
  </div>
948
  """
949
 
 
951
  try:
952
  result = coordinator_agent.process_files(files)
953
 
954
+ # Wait a moment for processing to complete
955
  import time
956
  time.sleep(3)
957
 
958
  success_html = """
959
+ <div style="background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.08));
960
+ border: 2px solid rgba(76, 175, 80, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
961
+ color: #4caf50; text-align: center; backdrop-filter: blur(10px);
962
+ box-shadow: 0 0 20px rgba(76, 175, 80, 0.1);">
963
+ βœ… Documents processed successfully! You can now ask questions about your content.
964
  </div>
965
  """
966
  return gr.update(value=success_html, visible=True), True
967
 
968
  except Exception as e:
969
  error_html = f"""
970
+ <div style="background: linear-gradient(135deg, rgba(244, 67, 54, 0.15), rgba(244, 67, 54, 0.08));
971
+ border: 2px solid rgba(244, 67, 54, 0.3); border-radius: 12px; padding: 1rem 1.5rem;
972
+ color: #f44336; text-align: center; backdrop-filter: blur(10px);
973
+ box-shadow: 0 0 20px rgba(244, 67, 54, 0.1);">
974
+ ❌ Error processing documents: {str(e)}
975
  </div>
976
  """
977
  return gr.update(value=error_html, visible=True), False
978
 
979
  def respond(message, history, doc_ready):
980
  if not doc_ready:
981
+ # Show error message
982
  history.append({"role": "user", "content": message})
983
+ history.append({"role": "assistant", "content": "⚠️ Please upload and process documents first before asking questions."})
984
  return history, ""
985
 
986
  if not message.strip():
 
996
  history[-1]["content"] += token
997
  yield history, ""
998
  except Exception as e:
999
+ history[-1]["content"] = f"❌ Error generating response: {str(e)}"
1000
  yield history, ""
1001
 
1002
  # Event bindings