Spaces:
Sleeping
Sleeping
fix
Browse files
main.py
CHANGED
|
@@ -550,12 +550,8 @@ def main():
|
|
| 550 |
return m;
|
| 551 |
}
|
| 552 |
|
| 553 |
-
function getMsgSpan() {
|
| 554 |
-
|
| 555 |
-
}
|
| 556 |
-
function getTimerSpan() {
|
| 557 |
-
return document.getElementById("processing-timer") || (root() ? root().querySelector("#processing-timer") : null);
|
| 558 |
-
}
|
| 559 |
|
| 560 |
function setMsg(t) { var s = getMsgSpan(); if (s) s.textContent = t; }
|
| 561 |
function fmtElapsed() { return ((Date.now() - startMs) / 1000).toFixed(1) + "s elapsed"; }
|
|
@@ -565,12 +561,12 @@ def main():
|
|
| 565 |
startMs = Date.now();
|
| 566 |
setMsg(pickMsg());
|
| 567 |
|
| 568 |
-
msgInterval = setInterval(function(){ setMsg(pickMsg()); }, 2000);
|
| 569 |
|
| 570 |
var t = getTimerSpan();
|
| 571 |
if (t) {
|
| 572 |
t.textContent = fmtElapsed();
|
| 573 |
-
timerInterval = setInterval(function(){ t.textContent = fmtElapsed(); }, 200);
|
| 574 |
}
|
| 575 |
}
|
| 576 |
|
|
@@ -587,15 +583,17 @@ def main():
|
|
| 587 |
else stop();
|
| 588 |
}
|
| 589 |
|
| 590 |
-
|
| 591 |
-
|
|
|
|
|
|
|
| 592 |
|
| 593 |
window.addEventListener("load", tick);
|
| 594 |
setInterval(tick, 500);
|
| 595 |
})();
|
| 596 |
"""
|
| 597 |
|
| 598 |
-
with gr.Blocks(theme=gr.themes.Soft(), title="SmartDoc AI", css=css) as demo:
|
| 599 |
gr.Markdown("### SmartDoc AI - Document Q&A", elem_classes="app-title")
|
| 600 |
gr.Markdown("Upload your documents and ask questions. Answers will appear below, just like a chat.", elem_classes="app-description")
|
| 601 |
gr.Markdown("---")
|
|
@@ -885,16 +883,15 @@ def main():
|
|
| 885 |
if is_hf_space:
|
| 886 |
# Hugging Face Spaces configuration
|
| 887 |
logger.info("Running on Hugging Face Spaces")
|
| 888 |
-
demo.launch(server_name="0.0.0.0", server_port=7860
|
| 889 |
else:
|
| 890 |
# Local development configuration
|
| 891 |
configured_port = int(os.environ.get("GRADIO_SERVER_PORT", "7860"))
|
| 892 |
server_port = _find_open_port(configured_port)
|
| 893 |
logger.info(f"Launching Gradio on port {server_port}")
|
| 894 |
logger.info(f"Access the app at: http://127.0.0.1:{server_port}")
|
| 895 |
-
demo.launch(server_name="127.0.0.1", server_port=server_port, share=False
|
| 896 |
-
|
| 897 |
-
|
| 898 |
|
| 899 |
if __name__ == "__main__":
|
| 900 |
main()
|
|
|
|
| 550 |
return m;
|
| 551 |
}
|
| 552 |
|
| 553 |
+
function getMsgSpan() { var r = root(); return r ? r.querySelector("#processing-msg") : null; }
|
| 554 |
+
function getTimerSpan() { var r = root(); return r ? r.querySelector("#processing-timer") : null; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
|
| 556 |
function setMsg(t) { var s = getMsgSpan(); if (s) s.textContent = t; }
|
| 557 |
function fmtElapsed() { return ((Date.now() - startMs) / 1000).toFixed(1) + "s elapsed"; }
|
|
|
|
| 561 |
startMs = Date.now();
|
| 562 |
setMsg(pickMsg());
|
| 563 |
|
| 564 |
+
msgInterval = setInterval(function () { setMsg(pickMsg()); }, 2000);
|
| 565 |
|
| 566 |
var t = getTimerSpan();
|
| 567 |
if (t) {
|
| 568 |
t.textContent = fmtElapsed();
|
| 569 |
+
timerInterval = setInterval(function () { t.textContent = fmtElapsed(); }, 200);
|
| 570 |
}
|
| 571 |
}
|
| 572 |
|
|
|
|
| 583 |
else stop();
|
| 584 |
}
|
| 585 |
|
| 586 |
+
try {
|
| 587 |
+
var obs = new MutationObserver(tick);
|
| 588 |
+
obs.observe(document.body, { subtree: true, childList: true, attributes: true });
|
| 589 |
+
} catch (e) {}
|
| 590 |
|
| 591 |
window.addEventListener("load", tick);
|
| 592 |
setInterval(tick, 500);
|
| 593 |
})();
|
| 594 |
"""
|
| 595 |
|
| 596 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="SmartDoc AI", css=css, js=js) as demo:
|
| 597 |
gr.Markdown("### SmartDoc AI - Document Q&A", elem_classes="app-title")
|
| 598 |
gr.Markdown("Upload your documents and ask questions. Answers will appear below, just like a chat.", elem_classes="app-description")
|
| 599 |
gr.Markdown("---")
|
|
|
|
| 883 |
if is_hf_space:
|
| 884 |
# Hugging Face Spaces configuration
|
| 885 |
logger.info("Running on Hugging Face Spaces")
|
| 886 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 887 |
else:
|
| 888 |
# Local development configuration
|
| 889 |
configured_port = int(os.environ.get("GRADIO_SERVER_PORT", "7860"))
|
| 890 |
server_port = _find_open_port(configured_port)
|
| 891 |
logger.info(f"Launching Gradio on port {server_port}")
|
| 892 |
logger.info(f"Access the app at: http://127.0.0.1:{server_port}")
|
| 893 |
+
demo.launch(server_name="127.0.0.1", server_port=server_port, share=False)
|
| 894 |
+
|
|
|
|
| 895 |
|
| 896 |
if __name__ == "__main__":
|
| 897 |
main()
|