Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -333,6 +333,26 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 333 |
label="Your chats",
|
| 334 |
interactive=True
|
| 335 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
with gr.Row():
|
| 337 |
new_btn = gr.Button("➕ New Chat", variant="primary")
|
| 338 |
del_btn = gr.Button("🗑️ Delete", variant="stop")
|
|
|
|
| 333 |
label="Your chats",
|
| 334 |
interactive=True
|
| 335 |
)
|
| 336 |
+
# -----------------------
|
| 337 |
+
# Editable title input
|
| 338 |
+
# -----------------------
|
| 339 |
+
edit_title_box = gr.Textbox(label="✏️ Rename Chat", placeholder="Edit selected chat title...")
|
| 340 |
+
rename_btn = gr.Button("💾 Save Title")
|
| 341 |
+
|
| 342 |
+
def rename_session_cb(new_title, selected_label):
|
| 343 |
+
sid = label_to_id(selected_label)
|
| 344 |
+
if sid and new_title.strip():
|
| 345 |
+
conn = db()
|
| 346 |
+
cur = conn.cursor()
|
| 347 |
+
cur.execute("UPDATE sessions SET title=? WHERE id=?", (new_title.strip(), sid))
|
| 348 |
+
conn.commit()
|
| 349 |
+
conn.close()
|
| 350 |
+
|
| 351 |
+
labels, _ = list_sessions()
|
| 352 |
+
new_selected = next((lbl for lbl in labels if lbl.startswith(f"{sid} ")), None)
|
| 353 |
+
return gr.update(choices=labels, value=new_selected)
|
| 354 |
+
|
| 355 |
+
rename_btn.click(rename_session_cb, inputs=[edit_title_box, session_list], outputs=session_list)
|
| 356 |
with gr.Row():
|
| 357 |
new_btn = gr.Button("➕ New Chat", variant="primary")
|
| 358 |
del_btn = gr.Button("🗑️ Delete", variant="stop")
|