From 220c1797fce938d9a86e33e236867f456e4f26fa Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 28 Jun 2024 22:11:31 -0700 Subject: [PATCH] UI: do not show the "save character" button in the Chat tab --- js/main.js | 4 ++++ modules/ui_chat.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 460b3538..22fe4149 100644 --- a/js/main.js +++ b/js/main.js @@ -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"; @@ -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() { @@ -580,6 +583,7 @@ function restoreOriginalPosition() { originalParent.insertBefore(movedElement, originalParent.children[originalIndex]); } + document.getElementById("save-character").style.display = ""; movedElement.style.display = ""; } } diff --git a/modules/ui_chat.py b/modules/ui_chat.py index 7a7a3753..6942588e 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -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')