Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -401,9 +401,9 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 401 |
|
| 402 |
with gr.Row(equal_height=True):
|
| 403 |
with gr.Column(scale=1, min_width=260):
|
| 404 |
-
gr.Markdown("### 📁
|
| 405 |
|
| 406 |
-
#
|
| 407 |
session_list = gr.Radio(
|
| 408 |
choices=labels,
|
| 409 |
value=default_selected,
|
|
@@ -411,21 +411,22 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 411 |
interactive=True
|
| 412 |
)
|
| 413 |
|
| 414 |
-
#
|
| 415 |
-
with gr.Row():
|
| 416 |
-
new_btn = gr.Button("
|
| 417 |
-
|
| 418 |
-
|
|
|
|
|
|
|
| 419 |
|
| 420 |
-
#
|
| 421 |
edit_title_box = gr.Textbox(
|
| 422 |
-
label="
|
| 423 |
-
placeholder="
|
| 424 |
visible=False
|
| 425 |
)
|
| 426 |
-
save_title_btn = gr.Button("💾 Save Title", elem_id="save-title-btn", visible=False)
|
| 427 |
|
| 428 |
-
#
|
| 429 |
def rename_session_cb(new_title, selected_label):
|
| 430 |
sid = label_to_id(selected_label)
|
| 431 |
if sid and new_title.strip():
|
|
@@ -438,12 +439,15 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 438 |
# Refresh the session list and keep the same one selected
|
| 439 |
labels, _ = list_sessions()
|
| 440 |
new_selected = next((lbl for lbl in labels if lbl.startswith(f"{sid} ")), None)
|
| 441 |
-
return gr.update(choices=labels, value=new_selected)
|
| 442 |
|
| 443 |
-
|
| 444 |
-
|
|
|
|
|
|
|
|
|
|
| 445 |
|
| 446 |
-
#
|
| 447 |
gr.Markdown("### 🤖 Model Selection")
|
| 448 |
model_choice = gr.Dropdown(
|
| 449 |
choices=list(MODELS.keys()),
|
|
@@ -452,7 +456,7 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 452 |
interactive=True
|
| 453 |
)
|
| 454 |
|
| 455 |
-
#
|
| 456 |
gr.Markdown("### 📚 Dataset Selection")
|
| 457 |
dataset_choice = gr.Dropdown(
|
| 458 |
choices=DATASETS,
|
|
@@ -461,7 +465,7 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 461 |
interactive=True
|
| 462 |
)
|
| 463 |
|
| 464 |
-
#
|
| 465 |
gr.Markdown("### ⚙️ Generation Settings")
|
| 466 |
with gr.Group(elem_classes="system-message-compact"):
|
| 467 |
system_box = gr.Textbox(
|
|
@@ -475,7 +479,6 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 475 |
temperature = gr.Slider(0.0, 2.0, value=0.25, step=0.05, label="Temperature")
|
| 476 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 477 |
|
| 478 |
-
# --- Chatbot & Input Column ---
|
| 479 |
with gr.Column(scale=3):
|
| 480 |
chatbot = gr.Chatbot(label="Assistant", height=500, type="messages")
|
| 481 |
with gr.Row():
|
|
@@ -485,6 +488,7 @@ with gr.Blocks(title="Backend-Focused LLaMA/Mistral CRUD Assistant", theme=gr.th
|
|
| 485 |
regen_btn = gr.Button("Regenerate 🔁", variant="secondary")
|
| 486 |
|
| 487 |
|
|
|
|
| 488 |
# Wire callbacks — updated outputs so visibility changes flow correctly
|
| 489 |
refresh_btn.click(
|
| 490 |
refresh_sessions_cb,
|
|
|
|
| 401 |
|
| 402 |
with gr.Row(equal_height=True):
|
| 403 |
with gr.Column(scale=1, min_width=260):
|
| 404 |
+
gr.Markdown("### 📁 Sessions")
|
| 405 |
|
| 406 |
+
# Main session list
|
| 407 |
session_list = gr.Radio(
|
| 408 |
choices=labels,
|
| 409 |
value=default_selected,
|
|
|
|
| 411 |
interactive=True
|
| 412 |
)
|
| 413 |
|
| 414 |
+
# Row for actions just below the list (not at the very bottom)
|
| 415 |
+
with gr.Row(elem_id="session-actions-row"):
|
| 416 |
+
new_btn = gr.Button("New Chat", elem_id="new-chat-btn")
|
| 417 |
+
rename_btn = gr.Button("Rename", elem_id="rename-chat-btn", visible=False)
|
| 418 |
+
save_btn = gr.Button("Save", elem_id="save-title-btn", visible=False)
|
| 419 |
+
del_btn = gr.Button("Delete", elem_id="delete-chat-btn", visible=False)
|
| 420 |
+
refresh_btn = gr.Button("Refresh", elem_id="refresh-btn", visible=False)
|
| 421 |
|
| 422 |
+
# Rename textbox (hidden until Rename is clicked)
|
| 423 |
edit_title_box = gr.Textbox(
|
| 424 |
+
label="Edit Chat Name",
|
| 425 |
+
placeholder="Type new chat name here…",
|
| 426 |
visible=False
|
| 427 |
)
|
|
|
|
| 428 |
|
| 429 |
+
# Callbacks
|
| 430 |
def rename_session_cb(new_title, selected_label):
|
| 431 |
sid = label_to_id(selected_label)
|
| 432 |
if sid and new_title.strip():
|
|
|
|
| 439 |
# Refresh the session list and keep the same one selected
|
| 440 |
labels, _ = list_sessions()
|
| 441 |
new_selected = next((lbl for lbl in labels if lbl.startswith(f"{sid} ")), None)
|
| 442 |
+
return gr.update(choices=labels, value=new_selected), gr.update(value="")
|
| 443 |
|
| 444 |
+
save_btn.click(
|
| 445 |
+
rename_session_cb,
|
| 446 |
+
inputs=[edit_title_box, session_list],
|
| 447 |
+
outputs=[session_list, edit_title_box]
|
| 448 |
+
)
|
| 449 |
|
| 450 |
+
# -------- Model selection --------
|
| 451 |
gr.Markdown("### 🤖 Model Selection")
|
| 452 |
model_choice = gr.Dropdown(
|
| 453 |
choices=list(MODELS.keys()),
|
|
|
|
| 456 |
interactive=True
|
| 457 |
)
|
| 458 |
|
| 459 |
+
# -------- Dataset selection --------
|
| 460 |
gr.Markdown("### 📚 Dataset Selection")
|
| 461 |
dataset_choice = gr.Dropdown(
|
| 462 |
choices=DATASETS,
|
|
|
|
| 465 |
interactive=True
|
| 466 |
)
|
| 467 |
|
| 468 |
+
# -------- Generation settings --------
|
| 469 |
gr.Markdown("### ⚙️ Generation Settings")
|
| 470 |
with gr.Group(elem_classes="system-message-compact"):
|
| 471 |
system_box = gr.Textbox(
|
|
|
|
| 479 |
temperature = gr.Slider(0.0, 2.0, value=0.25, step=0.05, label="Temperature")
|
| 480 |
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
|
| 481 |
|
|
|
|
| 482 |
with gr.Column(scale=3):
|
| 483 |
chatbot = gr.Chatbot(label="Assistant", height=500, type="messages")
|
| 484 |
with gr.Row():
|
|
|
|
| 488 |
regen_btn = gr.Button("Regenerate 🔁", variant="secondary")
|
| 489 |
|
| 490 |
|
| 491 |
+
|
| 492 |
# Wire callbacks — updated outputs so visibility changes flow correctly
|
| 493 |
refresh_btn.click(
|
| 494 |
refresh_sessions_cb,
|