UI: do not show the "save character" button in the Chat tab

This commit is contained in:
oobabooga 2024-06-28 22:11:31 -07:00
parent f62aad3d59
commit 220c1797fc
2 changed files with 5 additions and 1 deletions

View File

@ -554,12 +554,14 @@ function moveToChatTab() {
const characterMenu = document.getElementById("character-menu"); const characterMenu = document.getElementById("character-menu");
const grandParent = characterMenu.parentElement.parentElement; const grandParent = characterMenu.parentElement.parentElement;
// Save the initial location for the character dropdown
if (!originalParent) { if (!originalParent) {
originalParent = grandParent.parentElement; originalParent = grandParent.parentElement;
originalIndex = Array.from(originalParent.children).indexOf(grandParent); originalIndex = Array.from(originalParent.children).indexOf(grandParent);
movedElement = 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\"]"); const instructRadio = document.querySelector("#chat-mode input[value=\"instruct\"]");
if (instructRadio && instructRadio.checked) { if (instructRadio && instructRadio.checked) {
grandParent.style.display = "none"; grandParent.style.display = "none";
@ -570,6 +572,7 @@ function moveToChatTab() {
let newPosition = newParent.children.length - 2; let newPosition = newParent.children.length - 2;
newParent.insertBefore(grandParent, newParent.children[newPosition]); newParent.insertBefore(grandParent, newParent.children[newPosition]);
document.getElementById("save-character").style.display = "none";
} }
function restoreOriginalPosition() { function restoreOriginalPosition() {
@ -580,6 +583,7 @@ function restoreOriginalPosition() {
originalParent.insertBefore(movedElement, originalParent.children[originalIndex]); originalParent.insertBefore(movedElement, originalParent.children[originalIndex]);
} }
document.getElementById("save-character").style.display = "";
movedElement.style.display = ""; movedElement.style.display = "";
} }
} }

View File

@ -103,7 +103,7 @@ def create_chat_settings_ui():
with gr.Row(): 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') 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) 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['delete_character'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu)
shared.gradio['name2'] = gr.Textbox(value='', lines=1, label='Character\'s name') shared.gradio['name2'] = gr.Textbox(value='', lines=1, label='Character\'s name')