This commit is contained in:
oobabooga 2024-01-09 16:27:50 -08:00
parent bec4e0a1ce
commit 89e7e107fc
5 changed files with 22 additions and 21 deletions

View file

@ -37,7 +37,7 @@ document.querySelector(".header_bar").addEventListener("click", function(event)
//------------------------------------------------
// Keyboard shortcuts
//------------------------------------------------
let previousTabId = 'chat-tab-button';
let previousTabId = "chat-tab-button";
document.addEventListener("keydown", function(event) {
// Stop generation on Esc pressed
@ -101,10 +101,10 @@ document.addEventListener("keydown", function(event) {
// Switch between tabs on Tab
else if (!event.ctrlKey && !event.shiftKey && event.key === "Tab") {
event.preventDefault();
var parametersButton = document.getElementById('parameters-button');
var parametersButton = document.getElementById("parameters-button");
var parentContainer = parametersButton.parentNode;
var selectedChild = parentContainer.querySelector('.selected');
if (selectedChild.id == 'parameters-button') {
var selectedChild = parentContainer.querySelector(".selected");
if (selectedChild.id == "parameters-button") {
document.getElementById(previousTabId).click();
} else {
previousTabId = selectedChild.id;
@ -401,7 +401,7 @@ window.addEventListener("resize", updateDocumentWidth);
//------------------------------------------------
// Focus on the rename text area when it becomes visible
//------------------------------------------------
const renameTextArea = document.getElementById('rename-row').querySelector('textarea');
const renameTextArea = document.getElementById("rename-row").querySelector("textarea");
function respondToVisibility(element, callback) {
var options = {

View file

@ -529,6 +529,7 @@ def load_history_after_deletion(state, idx):
histories = find_all_histories(state)
idx = min(int(idx), len(histories) - 1)
idx = max(0, idx)
if len(histories) > 0:
history = load_history(histories[idx], state['character_menu'], state['mode'])
@ -542,6 +543,7 @@ def load_history_after_deletion(state, idx):
def update_character_menu_after_deletion(idx):
characters = utils.get_available_characters()
idx = min(int(idx), len(characters) - 1)
idx = max(0, idx)
return gr.update(choices=characters, value=characters[idx])

View file

@ -246,7 +246,6 @@ def create_event_handlers():
shared.gradio['delete_chat'].click(lambda: [gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)], None, gradio(clear_arr))
shared.gradio['delete_chat-cancel'].click(lambda: [gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, gradio(clear_arr))
shared.gradio['delete_chat-confirm'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda x, y: str(chat.find_all_histories(x).index(y)), gradio('interface_state', 'unique_id'), gradio('temporary_text')).then(