Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -126,6 +126,7 @@ css = """
|
|
126 |
body {
|
127 |
background: var(--background) !important;
|
128 |
color: var(--text) !important;
|
|
|
129 |
}
|
130 |
|
131 |
.gr-box {
|
@@ -146,6 +147,7 @@ body {
|
|
146 |
#chatbot {
|
147 |
background: var(--chatbot-bg) !important;
|
148 |
border-color: var(--border) !important;
|
|
|
149 |
}
|
150 |
|
151 |
.gr-textbox input {
|
@@ -155,18 +157,26 @@ body {
|
|
155 |
.dark .gr-markdown {
|
156 |
color: var(--text) !important;
|
157 |
}
|
|
|
|
|
|
|
|
|
|
|
158 |
"""
|
159 |
|
160 |
with gr.Blocks(css=css, title="HROM-V1.5 Chatbot") as demo:
|
161 |
-
current_theme = gr.
|
162 |
|
163 |
with gr.Row():
|
164 |
with gr.Column(scale=3):
|
165 |
gr.Markdown("# HROM-V1.5 Chatbot")
|
166 |
chatbot = gr.Chatbot(height=500, elem_id="chatbot")
|
167 |
-
msg = gr.Textbox(label="Your Message",
|
|
|
|
|
|
|
168 |
|
169 |
-
with gr.Column(scale=1, min_width=300):
|
170 |
with gr.Accordion("βοΈ Settings", open=False):
|
171 |
with gr.Row():
|
172 |
theme_btn = gr.Button("π Dark Theme", variant="secondary")
|
@@ -178,27 +188,30 @@ with gr.Blocks(css=css, title="HROM-V1.5 Chatbot") as demo:
|
|
178 |
value=CONFIG["max_seq_len"] - max_response_length, step=1,
|
179 |
label="Context Window Size")
|
180 |
with gr.Row():
|
181 |
-
clear_btn = gr.Button("Clear
|
182 |
|
183 |
token_state = gr.State([])
|
|
|
184 |
|
185 |
def toggle_theme(theme):
|
186 |
new_theme = "dark" if theme == "light" else "light"
|
187 |
btn_text = "π Light Theme" if new_theme == "light" else "π Dark Theme"
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
192 |
)
|
|
|
193 |
|
194 |
theme_btn.click(
|
195 |
toggle_theme,
|
196 |
current_theme,
|
197 |
-
[current_theme, theme_btn]
|
198 |
-
_js="""(theme) => {
|
199 |
-
document.body.classList.toggle('dark');
|
200 |
-
return document.body.classList.contains('dark') ? 'dark' : 'light';
|
201 |
-
}"""
|
202 |
)
|
203 |
|
204 |
msg.submit(
|
|
|
126 |
body {
|
127 |
background: var(--background) !important;
|
128 |
color: var(--text) !important;
|
129 |
+
transition: all 0.3s ease;
|
130 |
}
|
131 |
|
132 |
.gr-box {
|
|
|
147 |
#chatbot {
|
148 |
background: var(--chatbot-bg) !important;
|
149 |
border-color: var(--border) !important;
|
150 |
+
min-height: 500px;
|
151 |
}
|
152 |
|
153 |
.gr-textbox input {
|
|
|
157 |
.dark .gr-markdown {
|
158 |
color: var(--text) !important;
|
159 |
}
|
160 |
+
|
161 |
+
.settings-panel {
|
162 |
+
border-left: 1px solid var(--border) !important;
|
163 |
+
padding-left: 20px !important;
|
164 |
+
}
|
165 |
"""
|
166 |
|
167 |
with gr.Blocks(css=css, title="HROM-V1.5 Chatbot") as demo:
|
168 |
+
current_theme = gr.State("light")
|
169 |
|
170 |
with gr.Row():
|
171 |
with gr.Column(scale=3):
|
172 |
gr.Markdown("# HROM-V1.5 Chatbot")
|
173 |
chatbot = gr.Chatbot(height=500, elem_id="chatbot")
|
174 |
+
msg = gr.Textbox(label="Your Message",
|
175 |
+
placeholder="Type your message...",
|
176 |
+
show_label=False,
|
177 |
+
container=False)
|
178 |
|
179 |
+
with gr.Column(scale=1, min_width=300, elem_classes="settings-panel"):
|
180 |
with gr.Accordion("βοΈ Settings", open=False):
|
181 |
with gr.Row():
|
182 |
theme_btn = gr.Button("π Dark Theme", variant="secondary")
|
|
|
188 |
value=CONFIG["max_seq_len"] - max_response_length, step=1,
|
189 |
label="Context Window Size")
|
190 |
with gr.Row():
|
191 |
+
clear_btn = gr.Button("π§Ή Clear History", variant="secondary")
|
192 |
|
193 |
token_state = gr.State([])
|
194 |
+
theme_css = gr.HTML("<style></style>")
|
195 |
|
196 |
def toggle_theme(theme):
|
197 |
new_theme = "dark" if theme == "light" else "light"
|
198 |
btn_text = "π Light Theme" if new_theme == "light" else "π Dark Theme"
|
199 |
+
css = """
|
200 |
+
<style>
|
201 |
+
body { background: %s !important; color: %s !important; }
|
202 |
+
.dark-mode { display: %s !important; }
|
203 |
+
</style>
|
204 |
+
""" % (
|
205 |
+
"var(--background)",
|
206 |
+
"var(--text)",
|
207 |
+
"block" if new_theme == "dark" else "none"
|
208 |
)
|
209 |
+
return new_theme, btn_text, css
|
210 |
|
211 |
theme_btn.click(
|
212 |
toggle_theme,
|
213 |
current_theme,
|
214 |
+
[current_theme, theme_btn, theme_css]
|
|
|
|
|
|
|
|
|
215 |
)
|
216 |
|
217 |
msg.submit(
|