Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -182,6 +182,30 @@ class XylariaChat:
|
|
| 182 |
padding: 10px;
|
| 183 |
height: 100vh;
|
| 184 |
overflow-y: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
|
| 187 |
/* Main chat area */
|
|
@@ -223,15 +247,20 @@ class XylariaChat:
|
|
| 223 |
with gr.Row():
|
| 224 |
# Sidebar for displaying chat history
|
| 225 |
with gr.Column(elem_id="sidebar", scale=1):
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
# Main chat interface
|
| 237 |
with gr.Column(elem_id="main-chat", scale=3):
|
|
@@ -275,6 +304,18 @@ class XylariaChat:
|
|
| 275 |
def toggle_page(choice):
|
| 276 |
return gr.Column.update(visible=choice == "chat"), gr.Column.update(visible=choice == "start")
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
# Submit prompt
|
| 279 |
btn.click(
|
| 280 |
fn=streaming_response,
|
|
|
|
| 182 |
padding: 10px;
|
| 183 |
height: 100vh;
|
| 184 |
overflow-y: auto;
|
| 185 |
+
transition: width 0.3s ease; /* Smooth transition for collapse */
|
| 186 |
+
width: 250px; /* Initial width */
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
#sidebar.collapsed {
|
| 190 |
+
width: 50px; /* Collapsed width */
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
#sidebar.collapsed #sidebar-content {
|
| 194 |
+
display: none; /* Hide content when collapsed */
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
#sidebar-content {
|
| 198 |
+
display: block;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
#collapse-button {
|
| 202 |
+
width: 100%;
|
| 203 |
+
margin-bottom: 10px;
|
| 204 |
+
background-color: transparent;
|
| 205 |
+
border: none;
|
| 206 |
+
cursor: pointer;
|
| 207 |
+
text-align: left;
|
| 208 |
+
padding: 5px;
|
| 209 |
}
|
| 210 |
|
| 211 |
/* Main chat area */
|
|
|
|
| 247 |
with gr.Row():
|
| 248 |
# Sidebar for displaying chat history
|
| 249 |
with gr.Column(elem_id="sidebar", scale=1):
|
| 250 |
+
# Collapse button
|
| 251 |
+
collapse_button = gr.Button("<<", elem_id="collapse-button")
|
| 252 |
+
|
| 253 |
+
# Sidebar content (in a nested column for easier hiding)
|
| 254 |
+
with gr.Column(elem_id="sidebar-content"):
|
| 255 |
+
gr.Markdown("### Chat History")
|
| 256 |
+
load_button = gr.Button("Load Chat History")
|
| 257 |
+
chat_list = gr.Markdown("No chat history found.")
|
| 258 |
+
|
| 259 |
+
load_button.click(
|
| 260 |
+
fn=lambda: gr.Markdown.update(value=self.format_chat_history()),
|
| 261 |
+
inputs=None,
|
| 262 |
+
outputs=[chat_list]
|
| 263 |
+
)
|
| 264 |
|
| 265 |
# Main chat interface
|
| 266 |
with gr.Column(elem_id="main-chat", scale=3):
|
|
|
|
| 304 |
def toggle_page(choice):
|
| 305 |
return gr.Column.update(visible=choice == "chat"), gr.Column.update(visible=choice == "start")
|
| 306 |
|
| 307 |
+
# Toggle sidebar visibility
|
| 308 |
+
def toggle_sidebar():
|
| 309 |
+
return gr.Column.update(visible=True)
|
| 310 |
+
|
| 311 |
+
collapse_button.click(
|
| 312 |
+
fn=lambda: (gr.Column.update(elem_id="sidebar"),
|
| 313 |
+
gr.Column.update(elem_id="sidebar-content")),
|
| 314 |
+
inputs=None,
|
| 315 |
+
outputs=[gr.Column(elem_id="sidebar"),
|
| 316 |
+
gr.Column(elem_id="sidebar-content")]
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
# Submit prompt
|
| 320 |
btn.click(
|
| 321 |
fn=streaming_response,
|