Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -382,7 +382,7 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 382 |
# editable title input (kept but small)
|
| 383 |
edit_title_box = gr.Textbox(label="Rename selected chat", placeholder="Type new title...", lines=1)
|
| 384 |
|
| 385 |
-
# rename callback
|
| 386 |
def rename_session_cb(new_title, selected_label):
|
| 387 |
sid = label_to_id(selected_label)
|
| 388 |
if sid and new_title and new_title.strip():
|
|
@@ -395,15 +395,6 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 395 |
new_selected = next((lbl for lbl in labels if lbl.startswith(f"{sid} ")), None)
|
| 396 |
return gr.update(choices=labels, value=new_selected)
|
| 397 |
|
| 398 |
-
# wire rename button
|
| 399 |
-
rename_btn.click(rename_session_cb, inputs=[edit_title_box, session_list], outputs=[session_list])
|
| 400 |
-
|
| 401 |
-
# wire other small buttons
|
| 402 |
-
# <-- FIXED: outputs must be component variables, not gr.update(...) dicts
|
| 403 |
-
new_btn.click(new_chat_cb, outputs=[session_list, chatbot, user_box])
|
| 404 |
-
del_btn.click(delete_chat_cb, inputs=[session_list], outputs=[session_list, chatbot])
|
| 405 |
-
refresh_btn.click(refresh_sessions_cb, outputs=[session_list])
|
| 406 |
-
|
| 407 |
gr.Markdown("### 🤖 Model")
|
| 408 |
model_choice = gr.Dropdown(
|
| 409 |
choices=list(MODELS.keys()),
|
|
@@ -439,12 +430,19 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 439 |
send_btn = gr.Button("Send ▶️", variant="primary")
|
| 440 |
regen_btn = gr.Button("Regenerate 🔁", variant="secondary")
|
| 441 |
|
| 442 |
-
# Hook up callbacks (
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
refresh_btn.click(refresh_sessions_cb, outputs=[session_list])
|
| 444 |
new_btn.click(new_chat_cb, outputs=[session_list, chatbot, user_box])
|
| 445 |
del_btn.click(delete_chat_cb, inputs=[session_list], outputs=[session_list, chatbot])
|
|
|
|
|
|
|
| 446 |
session_list.change(load_session_cb, inputs=[session_list], outputs=[chatbot])
|
| 447 |
|
|
|
|
| 448 |
send_btn.click(
|
| 449 |
send_cb,
|
| 450 |
inputs=[user_box, session_list, chatbot, system_box, max_tokens, temperature, top_p, model_choice, dataset_choice],
|
|
|
|
| 382 |
# editable title input (kept but small)
|
| 383 |
edit_title_box = gr.Textbox(label="Rename selected chat", placeholder="Type new title...", lines=1)
|
| 384 |
|
| 385 |
+
# rename callback (kept unchanged)
|
| 386 |
def rename_session_cb(new_title, selected_label):
|
| 387 |
sid = label_to_id(selected_label)
|
| 388 |
if sid and new_title and new_title.strip():
|
|
|
|
| 395 |
new_selected = next((lbl for lbl in labels if lbl.startswith(f"{sid} ")), None)
|
| 396 |
return gr.update(choices=labels, value=new_selected)
|
| 397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
gr.Markdown("### 🤖 Model")
|
| 399 |
model_choice = gr.Dropdown(
|
| 400 |
choices=list(MODELS.keys()),
|
|
|
|
| 430 |
send_btn = gr.Button("Send ▶️", variant="primary")
|
| 431 |
regen_btn = gr.Button("Regenerate 🔁", variant="secondary")
|
| 432 |
|
| 433 |
+
# Hook up callbacks (moved here so chatbot & user_box exist)
|
| 434 |
+
# wire rename button (rename callback returns gr.update)
|
| 435 |
+
rename_btn.click(rename_session_cb, inputs=[edit_title_box, session_list], outputs=[session_list])
|
| 436 |
+
|
| 437 |
+
# wire other small buttons - use components in outputs (not gr.update)
|
| 438 |
refresh_btn.click(refresh_sessions_cb, outputs=[session_list])
|
| 439 |
new_btn.click(new_chat_cb, outputs=[session_list, chatbot, user_box])
|
| 440 |
del_btn.click(delete_chat_cb, inputs=[session_list], outputs=[session_list, chatbot])
|
| 441 |
+
|
| 442 |
+
# session load/change
|
| 443 |
session_list.change(load_session_cb, inputs=[session_list], outputs=[chatbot])
|
| 444 |
|
| 445 |
+
# main conversation wiring
|
| 446 |
send_btn.click(
|
| 447 |
send_cb,
|
| 448 |
inputs=[user_box, session_list, chatbot, system_box, max_tokens, temperature, top_p, model_choice, dataset_choice],
|