Skip to content

Commit

Permalink
UI: do not show the "save character" button in the Chat tab
Browse files Browse the repository at this point in the history
  • Loading branch information
oobabooga committed Jun 29, 2024
1 parent f62aad3 commit 220c179
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,14 @@ function moveToChatTab() {
const characterMenu = document.getElementById("character-menu");
const grandParent = characterMenu.parentElement.parentElement;

// Save the initial location for the character dropdown
if (!originalParent) {
originalParent = grandParent.parentElement;
originalIndex = Array.from(originalParent.children).indexOf(grandParent);
movedElement = grandParent;
}

// Do not show the Character dropdown in the Chat tab when "instruct" mode is selected
const instructRadio = document.querySelector("#chat-mode input[value=\"instruct\"]");
if (instructRadio && instructRadio.checked) {
grandParent.style.display = "none";
Expand All @@ -570,6 +572,7 @@ function moveToChatTab() {
let newPosition = newParent.children.length - 2;

newParent.insertBefore(grandParent, newParent.children[newPosition]);
document.getElementById("save-character").style.display = "none";
}

function restoreOriginalPosition() {
Expand All @@ -580,6 +583,7 @@ function restoreOriginalPosition() {
originalParent.insertBefore(movedElement, originalParent.children[originalIndex]);
}

document.getElementById("save-character").style.display = "";
movedElement.style.display = "";
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/ui_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create_chat_settings_ui():
with gr.Row():
shared.gradio['character_menu'] = gr.Dropdown(value=None, choices=utils.get_available_characters(), label='Character', elem_id='character-menu', info='Used in chat and chat-instruct modes.', elem_classes='slim-dropdown')
ui.create_refresh_button(shared.gradio['character_menu'], lambda: None, lambda: {'choices': utils.get_available_characters()}, 'refresh-button', interactive=not mu)
shared.gradio['save_character'] = gr.Button('💾', elem_classes='refresh-button', interactive=not mu)
shared.gradio['save_character'] = gr.Button('💾', elem_classes='refresh-button', elem_id="save-character", interactive=not mu)
shared.gradio['delete_character'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu)

shared.gradio['name2'] = gr.Textbox(value='', lines=1, label='Character\'s name')
Expand Down

0 comments on commit 220c179

Please sign in to comment.