Shreyas094
commited on
Commit
•
c2899d0
1
Parent(s):
c0cb1c5
Update app.py
Browse files
app.py
CHANGED
@@ -657,10 +657,6 @@ use_web_search = gr.Checkbox(label="Use Web Search", value=False)
|
|
657 |
|
658 |
custom_placeholder = "Ask a question (Note: You can toggle between Web Search and PDF Chat in Additional Inputs below)"
|
659 |
|
660 |
-
# Update the demo interface
|
661 |
-
# Update the Gradio interface
|
662 |
-
import gradio as gr
|
663 |
-
|
664 |
# Define a custom CSS for dark mode
|
665 |
dark_mode_css = """
|
666 |
.dark-mode {
|
@@ -676,6 +672,14 @@ dark_mode_css = """
|
|
676 |
}
|
677 |
"""
|
678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
# Create a function to toggle dark mode
|
680 |
def toggle_dark_mode(dark_mode):
|
681 |
return not dark_mode, gr.update(value="Light Mode" if dark_mode else "Dark Mode")
|
@@ -776,20 +780,8 @@ with demo:
|
|
776 |
dark_mode_button.click(
|
777 |
toggle_dark_mode,
|
778 |
inputs=[dark_mode],
|
779 |
-
outputs=[dark_mode, dark_mode_button]
|
780 |
-
|
781 |
-
|
782 |
-
# Add a function to update the CSS classes based on dark mode state
|
783 |
-
def update_dark_mode(dark_mode):
|
784 |
-
return {
|
785 |
-
"body": "dark-mode" if dark_mode else "",
|
786 |
-
".gradio-container": "dark-mode" if dark_mode else "",
|
787 |
-
}
|
788 |
-
|
789 |
-
dark_mode.change(
|
790 |
-
update_dark_mode,
|
791 |
-
inputs=[dark_mode],
|
792 |
-
outputs=[gr.HTMLClasses()]
|
793 |
)
|
794 |
|
795 |
if __name__ == "__main__":
|
|
|
657 |
|
658 |
custom_placeholder = "Ask a question (Note: You can toggle between Web Search and PDF Chat in Additional Inputs below)"
|
659 |
|
|
|
|
|
|
|
|
|
660 |
# Define a custom CSS for dark mode
|
661 |
dark_mode_css = """
|
662 |
.dark-mode {
|
|
|
672 |
}
|
673 |
"""
|
674 |
|
675 |
+
# JavaScript to toggle dark mode
|
676 |
+
dark_mode_js = """
|
677 |
+
function toggleDarkMode() {
|
678 |
+
document.body.classList.toggle('dark-mode');
|
679 |
+
return document.body.classList.contains('dark-mode');
|
680 |
+
}
|
681 |
+
"""
|
682 |
+
|
683 |
# Create a function to toggle dark mode
|
684 |
def toggle_dark_mode(dark_mode):
|
685 |
return not dark_mode, gr.update(value="Light Mode" if dark_mode else "Dark Mode")
|
|
|
780 |
dark_mode_button.click(
|
781 |
toggle_dark_mode,
|
782 |
inputs=[dark_mode],
|
783 |
+
outputs=[dark_mode, dark_mode_button],
|
784 |
+
_js=dark_mode_js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
785 |
)
|
786 |
|
787 |
if __name__ == "__main__":
|