TilanB commited on
Commit
805a89f
·
verified ·
1 Parent(s): 070e2e1
Files changed (1) hide show
  1. main.py +3 -76
main.py CHANGED
@@ -517,82 +517,9 @@ def main():
517
  margin-bottom: 16px !important;
518
  }
519
  """
520
- js = r"""
521
- (() => {
522
- const uploadMessages = [
523
- "Crunching your documents...",
524
- "Warming up the AI...",
525
- "Extracting knowledge...",
526
- "Scanning for insights...",
527
- "Preparing your data...",
528
- "Looking for answers...",
529
- "Analyzing file structure...",
530
- "Reading your files...",
531
- "Indexing content...",
532
- "Almost ready..."
533
- ];
534
-
535
- let msgInterval = null;
536
- let timerInterval = null;
537
- let startMs = 0;
538
- let lastMsg = null;
539
-
540
- const root = () => document.getElementById("processing-message");
541
- const isVisible = (el) => !!(el && (el.offsetWidth || el.offsetHeight || el.getClientRects().length));
542
-
543
- const pickMsg = () => {
544
- if (uploadMessages.length === 0) return "";
545
- if (uploadMessages.length === 1) return uploadMessages[0];
546
- let m;
547
- do { m = uploadMessages[Math.floor(Math.random() * uploadMessages.length)]; }
548
- while (m === lastMsg);
549
- lastMsg = m;
550
- return m;
551
- };
552
-
553
- const getMsgSpan = () => root()?.querySelector("#processing-msg");
554
- const getTimerSpan = () => root()?.querySelector("#processing-timer");
555
-
556
- const setMsg = (t) => { const s = getMsgSpan(); if (s) s.textContent = t; };
557
- const fmtElapsed = () => `${((Date.now() - startMs) / 1000).toFixed(1)}s elapsed`;
558
-
559
- const start = () => {
560
- if (msgInterval || timerInterval) return;
561
- startMs = Date.now();
562
- setMsg(pickMsg());
563
-
564
- msgInterval = setInterval(() => setMsg(pickMsg()), 2000);
565
-
566
- const t = getTimerSpan();
567
- if (t) {
568
- t.textContent = fmtElapsed();
569
- timerInterval = setInterval(() => { t.textContent = fmtElapsed(); }, 200);
570
- }
571
- };
572
-
573
- const stop = () => {
574
- if (msgInterval) { clearInterval(msgInterval); msgInterval = null; }
575
- if (timerInterval) { clearInterval(timerInterval); timerInterval = null; }
576
- const t = getTimerSpan();
577
- if (t) t.textContent = "";
578
- };
579
-
580
- const tick = () => {
581
- const r = root();
582
- if (isVisible(r)) start();
583
- else stop();
584
- };
585
-
586
- const obs = new MutationObserver(tick);
587
- obs.observe(document.body, { subtree: true, childList: true, attributes: true });
588
-
589
- window.addEventListener("load", tick);
590
- setInterval(tick, 500); // fallback
591
- })();
592
-
593
- """
594
-
595
- with gr.Blocks(theme=gr.themes.Soft(), title="SmartDoc AI", css=css, js=js) as demo:
596
  gr.Markdown("### SmartDoc AI - Document Q&A", elem_classes="app-title")
597
  gr.Markdown("Upload your documents and ask questions. Answers will appear below, just like a chat.", elem_classes="app-description")
598
  gr.Markdown("---")
 
517
  margin-bottom: 16px !important;
518
  }
519
  """
520
+
521
+
522
+ with gr.Blocks(theme=gr.themes.Soft(), title="SmartDoc AI", css=css) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  gr.Markdown("### SmartDoc AI - Document Q&A", elem_classes="app-title")
524
  gr.Markdown("Upload your documents and ask questions. Answers will appear below, just like a chat.", elem_classes="app-description")
525
  gr.Markdown("---")