From 89e7e107fc9bc92709aaf77a9ec4bbf55f7aad69 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 9 Jan 2024 16:27:50 -0800 Subject: [PATCH] Lint --- js/main.js | 18 +++++++++--------- modules/RoPE.py | 4 ++-- modules/chat.py | 2 ++ modules/models.py | 16 ++++++++-------- modules/ui_chat.py | 3 +-- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/js/main.js b/js/main.js index fda64bfc..bc8c785d 100644 --- a/js/main.js +++ b/js/main.js @@ -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,14 +101,14 @@ 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') { - document.getElementById(previousTabId).click(); + var selectedChild = parentContainer.querySelector(".selected"); + if (selectedChild.id == "parameters-button") { + document.getElementById(previousTabId).click(); } else { - previousTabId = selectedChild.id; - parametersButton.click(); + previousTabId = selectedChild.id; + parametersButton.click(); } } }); @@ -262,7 +262,7 @@ button.addEventListener("click", function () { hideMenu(); } else { - showMenu(); + showMenu(); } }); @@ -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 = { diff --git a/modules/RoPE.py b/modules/RoPE.py index c15616c6..31163a33 100644 --- a/modules/RoPE.py +++ b/modules/RoPE.py @@ -3,7 +3,7 @@ def get_alpha_value(alpha, base): Gets alpha_value from alpha_value and rope_freq_base ''' if base > 0: - return (base/10000.) ** (63/64.) + return (base / 10000.) ** (63 / 64.) else: return alpha @@ -15,4 +15,4 @@ def get_rope_freq_base(alpha, base): if base > 0: return base else: - return 10000 * alpha ** (64/63.) + return 10000 * alpha ** (64 / 63.) diff --git a/modules/chat.py b/modules/chat.py index c12a7fd4..5380f1ac 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -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]) diff --git a/modules/models.py b/modules/models.py index efdae7cb..e94dd12f 100644 --- a/modules/models.py +++ b/modules/models.py @@ -309,14 +309,14 @@ def AutoAWQ_loader(model_name): model_dir = Path(f'{shared.args.model_dir}/{model_name}') model = AutoAWQForCausalLM.from_quantized( - quant_path=model_dir, - max_new_tokens=shared.args.max_seq_len, - trust_remote_code=shared.args.trust_remote_code, - fuse_layers=not shared.args.no_inject_fused_attention, - max_memory=get_max_memory_dict(), - batch_size=1, - safetensors=any(model_dir.glob('*.safetensors')), - ) + quant_path=model_dir, + max_new_tokens=shared.args.max_seq_len, + trust_remote_code=shared.args.trust_remote_code, + fuse_layers=not shared.args.no_inject_fused_attention, + max_memory=get_max_memory_dict(), + batch_size=1, + safetensors=any(model_dir.glob('*.safetensors')), + ) return model diff --git a/modules/ui_chat.py b/modules/ui_chat.py index 4ef96832..a1b1af97 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -60,7 +60,7 @@ def create_ui(): shared.gradio['send-chat-to-default'] = gr.Button('Send to default') shared.gradio['send-chat-to-notebook'] = gr.Button('Send to notebook') - with gr.Row(elem_id='past-chats-row', elem_classes=['pretty_scrollbar']): + with gr.Row(elem_id='past-chats-row', elem_classes=['pretty_scrollbar']): with gr.Column(): with gr.Row(): shared.gradio['unique_id'] = gr.Dropdown(label='Past chats', elem_classes=['slim-dropdown'], interactive=not mu) @@ -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(