sofzcc commited on
Commit
d75dbd8
Β·
verified Β·
1 Parent(s): 50aebe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +315 -132
app.py CHANGED
@@ -496,6 +496,39 @@ def normalise_history(history: list) -> List[Tuple[str, str]]:
496
  return [(str(u or ""), str(a or "")) for u, a in history]
497
 
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  def build_answer(query: str, history: list) -> str:
500
  """Full RAG pipeline: FAISS retrieve β†’ sentence re-rank β†’ FLAN-T5 generate."""
501
  results = kb_index.retrieve(query)
@@ -514,15 +547,17 @@ def build_answer(query: str, history: list) -> str:
514
  "Please try rephrasing your question."
515
  )
516
 
 
517
  answer = generate_answer(query, context)
518
 
519
  if answer:
520
- return answer
521
 
522
  # Extractive fallback β€” surface the top re-ranked sentences directly
523
  return (
524
  "Here's the most relevant information I found:\n\n"
525
  + "\n".join(f"- {s}" for s in context.split("\n") if s.strip())
 
526
  )
527
 
528
 
@@ -678,13 +713,23 @@ def list_kb_files_html() -> str:
678
  <span class="kb-file-icon">{icon}</span>
679
  <span class="kb-file-name" title="{safe}">{name}</span>
680
  <div class="kb-file-actions">
681
- <button class="kb-action-btn" title="Delete"
682
- onclick="kbAction('delete','{safe}')">πŸ—‘</button>
683
- <button class="kb-action-btn" title="Replace"
684
  onclick="kbAction('replace','{safe}')">β†Ί</button>
 
 
685
  </div>
 
 
 
 
 
686
  </div>"""
687
- return items
 
 
 
688
 
689
 
690
  def rename_kb_file(old_name: str, new_name: str) -> Tuple[str, str]:
@@ -709,269 +754,406 @@ def rename_kb_file(old_name: str, new_name: str) -> Tuple[str, str]:
709
  # ── CSS ────────────────────────────────────────────────────────────────────────
710
 
711
  STYLE_HTML = """<style>
 
 
712
  :root {
713
- --sage:#6b8f71; --sage-l:#eaf2eb; --sage-d:#4f6e55;
714
- --sand:#f5f0e8; --cream:#fdfaf5; --stone:#e4ddd3; --stone2:#d4cdc3;
715
- --ink:#2d2d2d; --muted:#7a7167; --muted2:#a09890;
716
- --rose:#c0717a; --rose-l:#f8eded;
717
- --r:12px; --sh:0 2px 12px rgba(0,0,0,.08);
 
 
 
 
 
 
 
718
  }
 
719
  *, *::before, *::after { box-sizing: border-box; }
 
720
  body, .gradio-container {
721
  background: var(--sand) !important;
722
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
723
  color: var(--ink) !important;
 
724
  }
725
  .gradio-container { padding: 0 !important; max-width: 100% !important; }
726
 
727
- /* ── Header ─────────────────────────────────────────────────── */
728
  .app-hdr {
729
- background: var(--cream); border-bottom: 1px solid var(--stone);
730
- padding: 13px 20px; display: flex; align-items: center; gap: 12px;
731
- position: sticky; top: 0; z-index: 10;
 
 
 
 
732
  }
733
  .app-hdr-icon {
734
- width: 36px; height: 36px; background: var(--sage); border-radius: 9px;
735
- display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
736
  }
737
- .app-hdr h1 { margin: 0 0 1px; font-size: 1rem; font-weight: 650; color: var(--ink); }
738
- .app-hdr p { margin: 0; font-size: .74rem; color: var(--muted); }
739
 
740
- /* ── 3-column layout ─────────────────────────────────────────── */
741
  .app-body {
742
  display: grid;
743
- grid-template-columns: 200px 1fr 220px;
744
- gap: 0;
745
- height: calc(100vh - 64px);
746
  overflow: hidden;
747
  }
748
- @media(max-width: 860px) {
749
  .app-body { grid-template-columns: 1fr; height: auto; overflow: visible; }
750
  .left-col, .right-col { display: none; }
751
  }
752
 
753
- /* ── Left: suggested questions ───────────────────────────────── */
754
  .left-col {
755
  border-right: 1px solid var(--stone); background: var(--cream);
756
  display: flex; flex-direction: column; overflow: hidden;
757
  }
758
  .left-col-hdr {
759
- padding: 14px 14px 8px; font-size: .68rem; font-weight: 700;
760
- letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
 
761
  border-bottom: 1px solid var(--stone); flex-shrink: 0;
 
 
 
 
 
 
762
  }
763
- .left-col-body { overflow-y: auto; padding: 10px 10px; flex: 1; }
 
 
764
  .suggestion-pill {
765
- display: block; width: 100%; text-align: left;
766
- background: transparent; border: 1.5px solid var(--stone);
767
- border-radius: 999px; padding: 7px 13px;
768
- font-size: .77rem; color: var(--sage-d); cursor: pointer; margin-bottom: 7px;
769
- transition: background .15s, border-color .15s, color .15s;
770
- line-height: 1.4;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
771
  }
772
- .suggestion-pill:hover { background: var(--sage); border-color: var(--sage); color: #fff; }
773
 
774
- /* ── Centre: chat ────────────────────────────────────────────── */
775
  .centre-col {
776
  display: flex; flex-direction: column; overflow: hidden;
777
  background: var(--sand);
778
  }
779
 
780
- /* Kill ALL Gradio chrome β€” chatbot label, panel borders, etc. */
781
- /* Svelte hashes change between Gradio versions; target structurally instead */
782
  [data-testid="chatbot"] > .label-wrap,
783
  [data-testid="chatbot"] > div > .label-wrap,
784
  [data-testid="chatbot"] label,
785
  [data-testid="chatbot"] .label-wrap,
786
- .chatbot-label,
787
- .label-wrap span, /* hide text but let icon survive if any */
788
  .gr-chatbot-container .label-wrap,
789
- /* catch the actual rendered element seen in screenshot (☰ Chatbot) */
790
  .chatbot > .panel > .label,
791
  div[class*="label"] > span:only-child,
792
  .block > .label-wrap { display: none !important; }
793
- /* Belt-and-braces: hide via JS after render too (see script below) */
794
  .gr-chatbot, [data-testid="chatbot"] {
795
  flex: 1 !important; height: 100% !important;
796
  border: none !important; border-radius: 0 !important; background: transparent !important;
797
  }
798
  footer { display: none !important; }
799
 
800
- /* Bubbles */
 
 
 
 
 
801
  .message.user > div {
802
- background: var(--sage) !important; color: #fff !important;
 
803
  border-radius: var(--r) var(--r) 4px var(--r) !important;
804
- padding: 9px 14px !important; max-width: 75% !important;
805
- font-size: .88rem !important; line-height: 1.6 !important; box-shadow: var(--sh) !important;
 
806
  }
807
  .message.bot > div {
808
  background: var(--cream) !important; border: 1px solid var(--stone) !important;
809
  border-radius: var(--r) var(--r) var(--r) 4px !important;
810
- padding: 11px 15px !important; max-width: 80% !important;
811
- font-size: .88rem !important; line-height: 1.65 !important;
812
  box-shadow: var(--sh) !important; color: var(--ink) !important;
813
  }
 
 
 
 
 
 
814
 
815
- /* ── Merged input + toolbar box ──────────────────────────────── */
816
- /* Wrap the Gradio input area + our toolbar inside one rounded border */
817
  .chat-input-container {
818
  background: var(--cream) !important;
819
  border-top: 1px solid var(--stone) !important;
820
- padding: 10px 12px 4px !important;
821
  flex-shrink: 0;
822
  }
823
- /* The inner row Gradio renders: give it a rounded bordered card look */
824
  .chat-input-container > .wrap,
825
  .chat-input-container > div:first-child {
826
  border: 1.5px solid var(--stone) !important;
827
- border-radius: 12px 12px 0 0 !important;
828
- overflow: hidden !important;
829
- background: var(--sand) !important;
830
- transition: border-color .18s, box-shadow .18s !important;
831
  }
832
  .chat-input-container > .wrap:focus-within,
833
  .chat-input-container > div:first-child:focus-within {
834
  border-color: var(--sage) !important;
835
- box-shadow: 0 0 0 3px rgba(107,143,113,.14) !important;
836
  }
837
  .chat-input-container textarea {
838
- background: var(--sand) !important;
839
- border: none !important; /* border lives on parent now */
840
- border-radius: 0 !important;
841
- padding: 10px 13px !important;
842
- font-size: .88rem !important; color: var(--ink) !important;
843
- resize: none !important;
844
- }
845
- .chat-input-container textarea:focus {
846
- outline: none !important;
847
- box-shadow: none !important; /* parent handles focus ring */
848
  }
 
849
  .chat-input-container textarea::placeholder { color: var(--muted2) !important; }
850
  .chat-input-container button[aria-label="Send"] {
851
- background: var(--sage) !important; color: #fff !important; border: none !important;
852
- border-radius: 9px !important; padding: 0 13px !important; height: 36px !important;
853
- font-weight: 600 !important; transition: background .15s !important; margin: 0 6px 0 0 !important;
854
- align-self: flex-end !important; margin-bottom: 6px !important;
 
 
 
 
 
 
855
  }
856
- .chat-input-container button[aria-label="Send"]:hover { background: var(--sage-d) !important; }
857
 
858
- /* ── Toolbar β€” sits flush below textarea, inside same border ─── */
859
  .tb-bar {
860
  display: flex; align-items: center; gap: 2px;
861
- padding: 4px 10px 6px;
862
- /* no border-top β€” it's inside the same card */
863
- background: var(--sand);
864
- border-top: 1px solid var(--stone);
865
- border-radius: 0 0 12px 12px;
866
- /* merge with the parent card */
867
- margin: 0 -1px -1px -1px; /* bleed to parent border edges */
868
  }
869
  .tb-btn {
870
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
871
- background: none; border: none; border-radius: 5px; cursor: pointer; color: var(--muted);
872
- transition: background .13s, color .13s; position: relative; flex-shrink: 0;
 
873
  }
874
  .tb-btn:hover { background: var(--sage-l); color: var(--sage-d); }
875
  .tb-btn svg { width: 13px; height: 13px; pointer-events: none; }
876
- .tb-sep { width: 1px; height: 14px; background: var(--stone); margin: 0 2px; flex-shrink: 0; }
877
  .tb-btn::after {
878
- content: attr(data-tip); position: absolute; bottom: calc(100% + 5px); left: 50%;
879
- transform: translateX(-50%); background: rgba(30,30,30,.9); color: #fff;
880
- font-size: .65rem; padding: 3px 7px; border-radius: 4px; white-space: nowrap;
881
  pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 99;
 
882
  }
883
  .tb-btn:hover::after { opacity: 1; }
884
 
885
- /* ── Right: file list ────────────────────────────────────────── */
886
  .right-col {
887
  border-left: 1px solid var(--stone); background: var(--cream);
888
  display: flex; flex-direction: column; overflow: hidden;
889
  }
890
  .right-col-hdr {
891
- padding: 12px 14px 10px; border-bottom: 1px solid var(--stone);
892
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
893
  }
894
  .right-col-title {
895
- font-size: .68rem; font-weight: 700; letter-spacing: .06em;
896
- text-transform: uppercase; color: var(--muted);
 
 
 
 
 
 
897
  }
898
- /* + Add file button */
 
 
 
 
 
 
 
899
  .add-file-btn-wrap { position: relative; display: inline-block; }
900
  .add-file-btn {
901
- background: var(--sage-l); border: 1.5px solid var(--sage);
902
- color: var(--sage-d); border-radius: 7px; padding: 4px 10px;
903
  font-size: .74rem; font-weight: 600; cursor: pointer;
904
- transition: background .15s, color .15s; white-space: nowrap;
905
- display: flex; align-items: center; gap: 4px;
 
 
 
 
 
 
906
  }
907
- .add-file-btn:hover { background: var(--sage); color: #fff; }
908
- /* Tooltip for add-file */
909
  .add-file-tooltip {
910
- display: none; position: absolute; top: calc(100% + 7px); right: 0;
911
- background: var(--ink); color: #fff; border-radius: 8px; padding: 9px 12px;
912
- font-size: .73rem; line-height: 1.6; white-space: nowrap; z-index: 50;
913
- box-shadow: 0 4px 16px rgba(0,0,0,.18); min-width: 200px;
 
 
 
 
 
 
914
  }
915
  .add-file-tooltip::before {
916
  content: ""; position: absolute; top: -5px; right: 14px;
917
  border-left: 5px solid transparent; border-right: 5px solid transparent;
918
  border-bottom: 5px solid var(--ink);
919
  }
 
 
 
920
  .add-file-btn-wrap:hover .add-file-tooltip { display: block; }
921
 
922
- .right-col-body { overflow-y: auto; padding: 6px 8px; flex: 1; }
923
 
924
  /* File rows */
925
  .kb-file-row {
926
- display: flex; align-items: center; gap: 7px;
927
- padding: 7px 8px; border-radius: 8px; cursor: default;
928
- transition: background .13s; position: relative;
929
  }
930
  .kb-file-row:hover { background: var(--sand); }
931
- .kb-file-icon { font-size: .85rem; flex-shrink: 0; }
932
  .kb-file-name {
933
- flex: 1; font-size: .78rem; color: var(--ink);
934
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
935
  }
936
  .kb-file-actions {
937
- display: none; gap: 2px; align-items: center; flex-shrink: 0;
938
  }
939
  .kb-file-row:hover .kb-file-actions { display: flex; }
940
  .kb-action-btn {
941
- background: none; border: none; cursor: pointer; font-size: .8rem;
942
- padding: 2px 4px; border-radius: 4px; color: var(--muted);
943
- transition: background .12s, color .12s;
944
  }
945
  .kb-action-btn:hover { background: var(--stone); color: var(--ink); }
 
946
 
947
- /* Rename inline input */
948
  .kb-rename-row {
949
- display: none; padding: 6px 8px; gap: 6px; align-items: center;
950
  }
951
  .kb-rename-row.active { display: flex; }
952
  .kb-rename-input {
953
- flex: 1; border: 1.5px solid var(--sage); border-radius: 6px;
954
- padding: 4px 8px; font-size: .76rem; background: var(--sand);
955
- color: var(--ink); outline: none;
956
  }
957
  .kb-rename-save {
958
- background: var(--sage); color: #fff; border: none; border-radius: 6px;
959
- padding: 4px 9px; font-size: .73rem; font-weight: 600; cursor: pointer;
 
960
  }
 
961
  .kb-rename-cancel {
962
- background: none; border: 1px solid var(--stone); border-radius: 6px;
963
- padding: 4px 7px; font-size: .73rem; color: var(--muted); cursor: pointer;
964
  }
965
 
966
- /* Status toast */
967
  .kb-toast {
968
- position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
969
- background: var(--ink); color: #fff; border-radius: 8px;
970
- padding: 8px 18px; font-size: .8rem; z-index: 999;
971
- opacity: 0; pointer-events: none; transition: opacity .2s;
972
- white-space: nowrap;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
973
  }
974
- .kb-toast.show { opacity: 1; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
975
  </style>
976
 
977
  <script>
@@ -1145,6 +1327,7 @@ with gr.Blocks(title=CONFIG["client"]["name"]) as demo:
1145
  <h1>{CONFIG["client"]["name"]}</h1>
1146
  <p>Search the knowledge base and get answers in plain language</p>
1147
  </div>
 
1148
  </div>""")
1149
 
1150
  # ── 3-column body ─────────────────────────────────────────────────
@@ -1181,11 +1364,11 @@ with gr.Blocks(title=CONFIG["client"]["name"]) as demo:
1181
  + Add file
1182
  </button>
1183
  <div class="add-file-tooltip">
1184
- <strong>Upload documents</strong><br>
1185
- Formats: .txt Β· .md Β· .pdf Β· .docx<br>
1186
- Max size: 10 MB per file<br>
1187
- Multiple files supported<br>
1188
- Index rebuilds automatically
1189
  </div>
1190
  </div>
1191
  </div>""")
 
496
  return [(str(u or ""), str(a or "")) for u, a in history]
497
 
498
 
499
+ def _source_chip(results: list) -> str:
500
+ """
501
+ Build a compact Markdown source-chip line from the top retrieved results.
502
+ Uses HTML inline (Gradio renders it inside bot messages) so we can style it properly.
503
+ Only shows unique filenames, ordered by relevance score, max 3.
504
+ """
505
+ seen: list = []
506
+ for _, src, score in results:
507
+ if src not in seen and score >= MIN_SIMILARITY:
508
+ seen.append(src)
509
+ if len(seen) == 3:
510
+ break
511
+ if not seen:
512
+ return ""
513
+
514
+ ext_icons = {".pdf": "πŸ“„", ".docx": "πŸ“", ".doc": "πŸ“", ".md": "πŸ“‹", ".txt": "πŸ“ƒ"}
515
+ chips = []
516
+ for name in seen:
517
+ ext = os.path.splitext(name)[1].lower()
518
+ icon = ext_icons.get(ext, "πŸ“„")
519
+ chips.append(
520
+ f'<span class="src-chip"><span class="src-chip-icon">{icon}</span>'
521
+ f'<span class="src-chip-name">{name}</span></span>'
522
+ )
523
+
524
+ return (
525
+ '\n\n<div class="src-row">'
526
+ '<span class="src-label">Source</span>'
527
+ + "".join(chips)
528
+ + '</div>'
529
+ )
530
+
531
+
532
  def build_answer(query: str, history: list) -> str:
533
  """Full RAG pipeline: FAISS retrieve β†’ sentence re-rank β†’ FLAN-T5 generate."""
534
  results = kb_index.retrieve(query)
 
547
  "Please try rephrasing your question."
548
  )
549
 
550
+ chip = _source_chip(results)
551
  answer = generate_answer(query, context)
552
 
553
  if answer:
554
+ return answer + chip
555
 
556
  # Extractive fallback β€” surface the top re-ranked sentences directly
557
  return (
558
  "Here's the most relevant information I found:\n\n"
559
  + "\n".join(f"- {s}" for s in context.split("\n") if s.strip())
560
+ + chip
561
  )
562
 
563
 
 
713
  <span class="kb-file-icon">{icon}</span>
714
  <span class="kb-file-name" title="{safe}">{name}</span>
715
  <div class="kb-file-actions">
716
+ <button class="kb-action-btn" title="Rename"
717
+ onclick="kbAction('rename','{safe}')">✎</button>
718
+ <button class="kb-action-btn" title="Replace file"
719
  onclick="kbAction('replace','{safe}')">β†Ί</button>
720
+ <button class="kb-action-btn del" title="Delete"
721
+ onclick="kbAction('delete','{safe}')">πŸ—‘</button>
722
  </div>
723
+ </div>
724
+ <div class="kb-rename-row" id="rrow-{safe}">
725
+ <input class="kb-rename-input" placeholder="{safe}" id="rinput-{safe}"/>
726
+ <button class="kb-rename-save" onclick="kbSaveRename('{safe}')">Save</button>
727
+ <button class="kb-rename-cancel" onclick="kbCancelRename('{safe}')">βœ•</button>
728
  </div>"""
729
+ count = len(paths)
730
+ return f'''<div style="padding:4px 8px 2px;font-size:.68rem;color:var(--muted2)">
731
+ {count} file{"s" if count != 1 else ""} indexed
732
+ </div>''' + items
733
 
734
 
735
  def rename_kb_file(old_name: str, new_name: str) -> Tuple[str, str]:
 
754
  # ── CSS ────────────────────────────────────────────────────────────────────────
755
 
756
  STYLE_HTML = """<style>
757
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
758
+
759
  :root {
760
+ /* Palette */
761
+ --sage:#6b8f71; --sage-l:#eaf2eb; --sage-d:#4f6e55; --sage-xl:#f2f8f3;
762
+ --sand:#f5f0e8; --cream:#fdfaf5; --stone:#e4ddd3; --stone2:#d0c8bd;
763
+ --ink:#2d2d2d; --ink2:#4a4540; --muted:#7a7167; --muted2:#a09890;
764
+ --rose:#c0717a; --rose-l:#f8eded;
765
+ /* Spacing & shape */
766
+ --r:13px; --r-sm:8px; --r-xs:5px;
767
+ /* Shadows */
768
+ --sh-sm: 0 1px 3px rgba(0,0,0,.07);
769
+ --sh: 0 2px 10px rgba(0,0,0,.08);
770
+ --sh-md: 0 4px 20px rgba(0,0,0,.10);
771
+ --sh-lg: 0 8px 32px rgba(0,0,0,.13);
772
  }
773
+
774
  *, *::before, *::after { box-sizing: border-box; }
775
+
776
  body, .gradio-container {
777
  background: var(--sand) !important;
778
+ font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
779
  color: var(--ink) !important;
780
+ -webkit-font-smoothing: antialiased;
781
  }
782
  .gradio-container { padding: 0 !important; max-width: 100% !important; }
783
 
784
+ /* ── Header ─────────────────────────────────────────── */
785
  .app-hdr {
786
+ background: var(--cream);
787
+ border-bottom: 1px solid var(--stone);
788
+ padding: 0 24px;
789
+ height: 58px;
790
+ display: flex; align-items: center; gap: 13px;
791
+ position: sticky; top: 0; z-index: 20;
792
+ box-shadow: var(--sh-sm);
793
  }
794
  .app-hdr-icon {
795
+ width: 36px; height: 36px;
796
+ background: linear-gradient(135deg, var(--sage) 0%, var(--sage-d) 100%);
797
+ border-radius: 10px;
798
+ display: flex; align-items: center; justify-content: center;
799
+ font-size: 1.1rem; flex-shrink: 0;
800
+ box-shadow: 0 2px 8px rgba(107,143,113,.35);
801
+ }
802
+ .app-hdr h1 {
803
+ margin: 0 0 1px; font-size: .97rem; font-weight: 650;
804
+ color: var(--ink); letter-spacing: -.01em;
805
+ }
806
+ .app-hdr p { margin: 0; font-size: .73rem; color: var(--muted); }
807
+ /* Subtle version badge */
808
+ .app-hdr-badge {
809
+ margin-left: auto;
810
+ background: var(--sage-xl); border: 1px solid var(--sage-l);
811
+ color: var(--sage-d); border-radius: 999px;
812
+ padding: 3px 10px; font-size: .68rem; font-weight: 600;
813
+ letter-spacing: .02em;
814
  }
 
 
815
 
816
+ /* ── 3-column layout ─────────────────────────────────── */
817
  .app-body {
818
  display: grid;
819
+ grid-template-columns: 210px 1fr 230px;
820
+ height: calc(100vh - 58px);
 
821
  overflow: hidden;
822
  }
823
+ @media(max-width: 900px) {
824
  .app-body { grid-template-columns: 1fr; height: auto; overflow: visible; }
825
  .left-col, .right-col { display: none; }
826
  }
827
 
828
+ /* ── Left col ────────────────────────────────────────── */
829
  .left-col {
830
  border-right: 1px solid var(--stone); background: var(--cream);
831
  display: flex; flex-direction: column; overflow: hidden;
832
  }
833
  .left-col-hdr {
834
+ padding: 16px 14px 10px;
835
+ font-size: .63rem; font-weight: 700; letter-spacing: .08em;
836
+ text-transform: uppercase; color: var(--muted2);
837
  border-bottom: 1px solid var(--stone); flex-shrink: 0;
838
+ display: flex; align-items: center; gap: 6px;
839
+ }
840
+ .left-col-hdr::before {
841
+ content: "";
842
+ display: inline-block; width: 6px; height: 6px;
843
+ background: var(--sage); border-radius: 50%;
844
  }
845
+ .left-col-body { overflow-y: auto; padding: 12px 10px 16px; flex: 1; }
846
+
847
+ /* Suggestion pills β€” staggered fade-in */
848
  .suggestion-pill {
849
+ display: flex; align-items: flex-start; gap: 8px;
850
+ width: 100%; text-align: left;
851
+ background: var(--cream); border: 1.5px solid var(--stone);
852
+ border-radius: var(--r); padding: 9px 12px;
853
+ font-size: .77rem; color: var(--ink2); cursor: pointer;
854
+ margin-bottom: 8px; line-height: 1.45;
855
+ transition: background .16s, border-color .16s, color .16s, transform .16s, box-shadow .16s;
856
+ box-shadow: var(--sh-sm);
857
+ opacity: 0; animation: pillFadeIn .4s ease forwards;
858
+ }
859
+ .suggestion-pill:nth-child(1) { animation-delay: .05s; }
860
+ .suggestion-pill:nth-child(2) { animation-delay: .12s; }
861
+ .suggestion-pill:nth-child(3) { animation-delay: .19s; }
862
+ .suggestion-pill:nth-child(4) { animation-delay: .26s; }
863
+ .suggestion-pill:nth-child(5) { animation-delay: .33s; }
864
+ .suggestion-pill::before {
865
+ content: "β†’"; color: var(--sage); font-size: .8rem;
866
+ flex-shrink: 0; margin-top: 1px; transition: transform .16s;
867
+ }
868
+ .suggestion-pill:hover {
869
+ background: var(--sage-xl); border-color: var(--sage);
870
+ color: var(--sage-d); transform: translateX(3px);
871
+ box-shadow: var(--sh);
872
+ }
873
+ .suggestion-pill:hover::before { transform: translateX(3px); }
874
+ @keyframes pillFadeIn {
875
+ from { opacity: 0; transform: translateY(6px); }
876
+ to { opacity: 1; transform: translateY(0); }
877
  }
 
878
 
879
+ /* ── Centre col ──────────────────────────────────────── */
880
  .centre-col {
881
  display: flex; flex-direction: column; overflow: hidden;
882
  background: var(--sand);
883
  }
884
 
885
+ /* Kill ALL Gradio chrome */
 
886
  [data-testid="chatbot"] > .label-wrap,
887
  [data-testid="chatbot"] > div > .label-wrap,
888
  [data-testid="chatbot"] label,
889
  [data-testid="chatbot"] .label-wrap,
890
+ .chatbot-label, .label-wrap span,
 
891
  .gr-chatbot-container .label-wrap,
 
892
  .chatbot > .panel > .label,
893
  div[class*="label"] > span:only-child,
894
  .block > .label-wrap { display: none !important; }
 
895
  .gr-chatbot, [data-testid="chatbot"] {
896
  flex: 1 !important; height: 100% !important;
897
  border: none !important; border-radius: 0 !important; background: transparent !important;
898
  }
899
  footer { display: none !important; }
900
 
901
+ /* ── Chat bubbles ─────────────────────────────────────── */
902
+ .message { animation: bubbleIn .22s ease; }
903
+ @keyframes bubbleIn {
904
+ from { opacity: 0; transform: translateY(8px); }
905
+ to { opacity: 1; transform: translateY(0); }
906
+ }
907
  .message.user > div {
908
+ background: linear-gradient(135deg, var(--sage) 0%, var(--sage-d) 100%) !important;
909
+ color: #fff !important;
910
  border-radius: var(--r) var(--r) 4px var(--r) !important;
911
+ padding: 10px 15px !important; max-width: 74% !important;
912
+ font-size: .875rem !important; line-height: 1.6 !important;
913
+ box-shadow: 0 3px 12px rgba(79,110,85,.30) !important;
914
  }
915
  .message.bot > div {
916
  background: var(--cream) !important; border: 1px solid var(--stone) !important;
917
  border-radius: var(--r) var(--r) var(--r) 4px !important;
918
+ padding: 12px 16px !important; max-width: 80% !important;
919
+ font-size: .875rem !important; line-height: 1.68 !important;
920
  box-shadow: var(--sh) !important; color: var(--ink) !important;
921
  }
922
+ /* Bot avatar dot */
923
+ .message.bot::before {
924
+ content: "πŸ€–";
925
+ display: block; font-size: .85rem; margin-bottom: 4px;
926
+ opacity: .7;
927
+ }
928
 
929
+ /* ── Input + toolbar card ────────────────────────────── */
 
930
  .chat-input-container {
931
  background: var(--cream) !important;
932
  border-top: 1px solid var(--stone) !important;
933
+ padding: 12px 14px 8px !important;
934
  flex-shrink: 0;
935
  }
936
+ /* Outer card border */
937
  .chat-input-container > .wrap,
938
  .chat-input-container > div:first-child {
939
  border: 1.5px solid var(--stone) !important;
940
+ border-radius: var(--r) var(--r) var(--r-sm) var(--r-sm) !important;
941
+ overflow: hidden !important; background: var(--sand) !important;
942
+ transition: border-color .2s, box-shadow .2s !important;
 
943
  }
944
  .chat-input-container > .wrap:focus-within,
945
  .chat-input-container > div:first-child:focus-within {
946
  border-color: var(--sage) !important;
947
+ box-shadow: 0 0 0 3px rgba(107,143,113,.15) !important;
948
  }
949
  .chat-input-container textarea {
950
+ background: var(--sand) !important; border: none !important;
951
+ border-radius: 0 !important; padding: 11px 14px !important;
952
+ font-size: .875rem !important; color: var(--ink) !important;
953
+ resize: none !important; font-family: inherit !important;
954
+ line-height: 1.55 !important;
 
 
 
 
 
955
  }
956
+ .chat-input-container textarea:focus { outline: none !important; box-shadow: none !important; }
957
  .chat-input-container textarea::placeholder { color: var(--muted2) !important; }
958
  .chat-input-container button[aria-label="Send"] {
959
+ background: linear-gradient(135deg, var(--sage) 0%, var(--sage-d) 100%) !important;
960
+ color: #fff !important; border: none !important;
961
+ border-radius: var(--r-sm) !important; padding: 0 15px !important; height: 36px !important;
962
+ font-weight: 600 !important; font-size: .82rem !important;
963
+ transition: opacity .15s, transform .1s !important;
964
+ margin: 0 7px 7px 0 !important; align-self: flex-end !important;
965
+ box-shadow: 0 2px 8px rgba(79,110,85,.28) !important;
966
+ }
967
+ .chat-input-container button[aria-label="Send"]:hover {
968
+ opacity: .88 !important; transform: translateY(-1px) !important;
969
  }
 
970
 
971
+ /* Toolbar β€” fused bottom of input card */
972
  .tb-bar {
973
  display: flex; align-items: center; gap: 2px;
974
+ padding: 5px 10px 7px;
975
+ background: var(--sand); border-top: 1px solid var(--stone);
976
+ border-radius: 0 0 var(--r-sm) var(--r-sm);
977
+ margin: 0 -1px -1px -1px;
 
 
 
978
  }
979
  .tb-btn {
980
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
981
+ background: none; border: none; border-radius: var(--r-xs);
982
+ cursor: pointer; color: var(--muted); transition: background .13s, color .13s;
983
+ position: relative; flex-shrink: 0;
984
  }
985
  .tb-btn:hover { background: var(--sage-l); color: var(--sage-d); }
986
  .tb-btn svg { width: 13px; height: 13px; pointer-events: none; }
987
+ .tb-sep { width: 1px; height: 13px; background: var(--stone2); margin: 0 3px; flex-shrink: 0; }
988
  .tb-btn::after {
989
+ content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
990
+ transform: translateX(-50%); background: var(--ink); color: #fff;
991
+ font-size: .63rem; padding: 3px 7px; border-radius: 4px; white-space: nowrap;
992
  pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 99;
993
+ font-family: "Inter", sans-serif;
994
  }
995
  .tb-btn:hover::after { opacity: 1; }
996
 
997
+ /* ── Right col ───────────────────────────────────────── */
998
  .right-col {
999
  border-left: 1px solid var(--stone); background: var(--cream);
1000
  display: flex; flex-direction: column; overflow: hidden;
1001
  }
1002
  .right-col-hdr {
1003
+ padding: 14px 14px 12px; border-bottom: 1px solid var(--stone);
1004
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
1005
  }
1006
  .right-col-title {
1007
+ font-size: .63rem; font-weight: 700; letter-spacing: .08em;
1008
+ text-transform: uppercase; color: var(--muted2);
1009
+ display: flex; align-items: center; gap: 6px;
1010
+ }
1011
+ .right-col-title::before {
1012
+ content: "";
1013
+ display: inline-block; width: 6px; height: 6px;
1014
+ background: var(--sage); border-radius: 50%;
1015
  }
1016
+ /* File count badge */
1017
+ .kb-count-badge {
1018
+ background: var(--sage-xl); color: var(--sage-d); border-radius: 999px;
1019
+ padding: 1px 8px; font-size: .68rem; font-weight: 600;
1020
+ border: 1px solid var(--sage-l);
1021
+ }
1022
+
1023
+ /* + Add file */
1024
  .add-file-btn-wrap { position: relative; display: inline-block; }
1025
  .add-file-btn {
1026
+ background: var(--sage-xl); border: 1.5px solid var(--sage-l);
1027
+ color: var(--sage-d); border-radius: var(--r-sm); padding: 5px 11px;
1028
  font-size: .74rem; font-weight: 600; cursor: pointer;
1029
+ transition: all .15s; white-space: nowrap;
1030
+ display: flex; align-items: center; gap: 5px;
1031
+ box-shadow: var(--sh-sm);
1032
+ }
1033
+ .add-file-btn:hover {
1034
+ background: var(--sage); color: #fff; border-color: var(--sage);
1035
+ box-shadow: 0 2px 8px rgba(107,143,113,.3);
1036
+ transform: translateY(-1px);
1037
  }
 
 
1038
  .add-file-tooltip {
1039
+ display: none; position: absolute; top: calc(100% + 8px); right: 0;
1040
+ background: var(--ink); color: #fff; border-radius: var(--r-sm);
1041
+ padding: 10px 13px; font-size: .72rem; line-height: 1.65;
1042
+ white-space: nowrap; z-index: 50;
1043
+ box-shadow: var(--sh-lg); min-width: 210px;
1044
+ animation: tooltipIn .14s ease;
1045
+ }
1046
+ @keyframes tooltipIn {
1047
+ from { opacity: 0; transform: translateY(-3px); }
1048
+ to { opacity: 1; transform: translateY(0); }
1049
  }
1050
  .add-file-tooltip::before {
1051
  content: ""; position: absolute; top: -5px; right: 14px;
1052
  border-left: 5px solid transparent; border-right: 5px solid transparent;
1053
  border-bottom: 5px solid var(--ink);
1054
  }
1055
+ .add-file-tooltip strong { display: block; margin-bottom: 4px; font-size: .76rem; }
1056
+ .add-file-tooltip .tt-row { display: flex; align-items: center; gap: 6px; opacity: .88; }
1057
+ .add-file-tooltip .tt-row::before { content: "β€’"; color: var(--sage-l); }
1058
  .add-file-btn-wrap:hover .add-file-tooltip { display: block; }
1059
 
1060
+ .right-col-body { overflow-y: auto; padding: 6px 8px 16px; flex: 1; }
1061
 
1062
  /* File rows */
1063
  .kb-file-row {
1064
+ display: flex; align-items: center; gap: 8px;
1065
+ padding: 7px 9px; border-radius: var(--r-sm); cursor: default;
1066
+ transition: background .13s;
1067
  }
1068
  .kb-file-row:hover { background: var(--sand); }
1069
+ .kb-file-icon { font-size: .82rem; flex-shrink: 0; opacity: .8; }
1070
  .kb-file-name {
1071
+ flex: 1; font-size: .775rem; color: var(--ink2);
1072
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
1073
  }
1074
  .kb-file-actions {
1075
+ display: none; gap: 1px; align-items: center; flex-shrink: 0;
1076
  }
1077
  .kb-file-row:hover .kb-file-actions { display: flex; }
1078
  .kb-action-btn {
1079
+ background: none; border: none; cursor: pointer; font-size: .78rem;
1080
+ padding: 3px 5px; border-radius: 4px; color: var(--muted);
1081
+ transition: background .12s, color .12s; line-height: 1;
1082
  }
1083
  .kb-action-btn:hover { background: var(--stone); color: var(--ink); }
1084
+ .kb-action-btn.del:hover { background: var(--rose-l); color: var(--rose); }
1085
 
1086
+ /* Rename inline */
1087
  .kb-rename-row {
1088
+ display: none; padding: 5px 8px; gap: 5px; align-items: center;
1089
  }
1090
  .kb-rename-row.active { display: flex; }
1091
  .kb-rename-input {
1092
+ flex: 1; border: 1.5px solid var(--sage); border-radius: var(--r-xs);
1093
+ padding: 4px 8px; font-size: .75rem; background: var(--sand);
1094
+ color: var(--ink); outline: none; font-family: inherit;
1095
  }
1096
  .kb-rename-save {
1097
+ background: var(--sage); color: #fff; border: none; border-radius: var(--r-xs);
1098
+ padding: 4px 9px; font-size: .72rem; font-weight: 600; cursor: pointer;
1099
+ transition: background .13s;
1100
  }
1101
+ .kb-rename-save:hover { background: var(--sage-d); }
1102
  .kb-rename-cancel {
1103
+ background: none; border: 1px solid var(--stone); border-radius: var(--r-xs);
1104
+ padding: 4px 7px; font-size: .72rem; color: var(--muted); cursor: pointer;
1105
  }
1106
 
1107
+ /* ── Toast notification ───────────────────────────────── */
1108
  .kb-toast {
1109
+ position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(6px);
1110
+ background: var(--ink); color: #fff; border-radius: var(--r-sm);
1111
+ padding: 9px 20px; font-size: .79rem; z-index: 9999;
1112
+ opacity: 0; pointer-events: none;
1113
+ transition: opacity .22s, transform .22s;
1114
+ white-space: nowrap; box-shadow: var(--sh-md);
1115
+ display: flex; align-items: center; gap: 8px;
1116
+ }
1117
+ .kb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
1118
+
1119
+ /* ── Source chip ────────────────────────────────────────── */
1120
+ .src-row {
1121
+ display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
1122
+ margin-top: 10px; padding-top: 9px;
1123
+ border-top: 1px solid var(--stone);
1124
+ }
1125
+ .src-label {
1126
+ font-size: .67rem; font-weight: 700; letter-spacing: .07em;
1127
+ text-transform: uppercase; color: var(--muted2);
1128
+ margin-right: 2px; flex-shrink: 0;
1129
+ }
1130
+ .src-chip {
1131
+ display: inline-flex; align-items: center; gap: 4px;
1132
+ background: var(--sage-xl); border: 1px solid var(--sage-l);
1133
+ border-radius: 999px; padding: 2px 10px 2px 7px;
1134
+ transition: background .14s, border-color .14s;
1135
+ animation: chipIn .22s ease;
1136
  }
1137
+ .src-chip:hover { background: var(--sage-l); border-color: var(--sage); }
1138
+ @keyframes chipIn {
1139
+ from { opacity: 0; transform: translateY(4px) scale(.95); }
1140
+ to { opacity: 1; transform: translateY(0) scale(1); }
1141
+ }
1142
+ .src-chip-icon { font-size: .72rem; }
1143
+ .src-chip-name {
1144
+ font-size: .72rem; font-weight: 500;
1145
+ color: var(--sage-d); max-width: 140px;
1146
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
1147
+ }
1148
+
1149
+ /* ── Scrollbar polish ─────────────────────────────────── */
1150
+ ::-webkit-scrollbar { width: 5px; }
1151
+ ::-webkit-scrollbar-track { background: transparent; }
1152
+ ::-webkit-scrollbar-thumb { background: var(--stone2); border-radius: 99px; }
1153
+ ::-webkit-scrollbar-thumb:hover { background: var(--muted2); }
1154
+
1155
+ /* ── Selection colour ─────────────────────────────────── */
1156
+ ::selection { background: rgba(107,143,113,.22); }
1157
  </style>
1158
 
1159
  <script>
 
1327
  <h1>{CONFIG["client"]["name"]}</h1>
1328
  <p>Search the knowledge base and get answers in plain language</p>
1329
  </div>
1330
+ <span class="app-hdr-badge">MVP Β· AI-powered</span>
1331
  </div>""")
1332
 
1333
  # ── 3-column body ─────────────────────────────────────────────────
 
1364
  + Add file
1365
  </button>
1366
  <div class="add-file-tooltip">
1367
+ <strong>Add to knowledge base</strong>
1368
+ <div class="tt-row">Formats: .txt Β· .md Β· .pdf Β· .docx</div>
1369
+ <div class="tt-row">Max size: 10 MB per file</div>
1370
+ <div class="tt-row">Multiple files at once supported</div>
1371
+ <div class="tt-row">Index rebuilds automatically</div>
1372
  </div>
1373
  </div>
1374
  </div>""")