Update app.py
Browse filesAdded dark/light mode toggle
app.py
CHANGED
@@ -21,5 +21,56 @@ def anjibot(message, history):
|
|
21 |
responses.append(answer)
|
22 |
return "AnjiBot: " + answer
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
demo_chatbot = gr.ChatInterface(anjibot, title='AnjiBot', description="Anji is unavailable? That girl! Ask me, I may know!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
demo_chatbot.launch()
|
|
|
21 |
responses.append(answer)
|
22 |
return "AnjiBot: " + answer
|
23 |
|
24 |
+
def toggle_theme(theme):
|
25 |
+
if theme == "dark":
|
26 |
+
demo_chatbot.style(stylesheet=dark_mode_css)
|
27 |
+
else:
|
28 |
+
demo_chatbot.style(stylesheet=light_mode_css)
|
29 |
+
|
30 |
+
# Dark and light mode CSS
|
31 |
+
dark_mode_css = """
|
32 |
+
body {
|
33 |
+
background-color: #1e1e1e;
|
34 |
+
color: #ffffff;
|
35 |
+
}
|
36 |
+
.gr-absolute-container {
|
37 |
+
background-color: #1e1e1e;
|
38 |
+
}
|
39 |
+
.gr-input {
|
40 |
+
background-color: #2a2a2a;
|
41 |
+
color: #ffffff;
|
42 |
+
}
|
43 |
+
.gr-output {
|
44 |
+
background-color: #2a2a2a;
|
45 |
+
color: #ffffff;
|
46 |
+
}
|
47 |
+
"""
|
48 |
+
|
49 |
+
light_mode_css = """
|
50 |
+
body {
|
51 |
+
background-color: #ffffff;
|
52 |
+
color: #000000;
|
53 |
+
}
|
54 |
+
.gr-absolute-container {
|
55 |
+
background-color: #ffffff;
|
56 |
+
}
|
57 |
+
.gr-input {
|
58 |
+
background-color: #eeeeee;
|
59 |
+
color: #000000;
|
60 |
+
}
|
61 |
+
.gr-output {
|
62 |
+
background-color: #eeeeee;
|
63 |
+
color: #000000;
|
64 |
+
}
|
65 |
+
"""
|
66 |
+
|
67 |
+
|
68 |
demo_chatbot = gr.ChatInterface(anjibot, title='AnjiBot', description="Anji is unavailable? That girl! Ask me, I may know!")
|
69 |
+
|
70 |
+
theme_button = gr.Button("Toggle Theme", toggle_theme, default="light", choices=["light", "dark"])
|
71 |
+
demo_chatbot.add_input(theme_button)
|
72 |
+
|
73 |
+
|
74 |
+
demo_chatbot.style(stylesheet=light_mode_css)
|
75 |
+
|
76 |
demo_chatbot.launch()
|