From 8c51b405e4927655f684dda0cb27a442de91e8d6 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 31 Mar 2023 23:41:10 -0300 Subject: [PATCH] Progress towards generalizing Interface mode tab --- server.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server.py b/server.py index 225a1f4c..ebd9c81e 100644 --- a/server.py +++ b/server.py @@ -217,10 +217,11 @@ def create_settings_menus(default_preset): shared.gradio['softprompts_menu'].change(load_soft_prompt, [shared.gradio['softprompts_menu']], [shared.gradio['softprompts_menu']], show_progress=True) shared.gradio['upload_softprompt'].upload(upload_soft_prompt, [shared.gradio['upload_softprompt']], [shared.gradio['softprompts_menu']]) -def set_interface_arguments(interface_mode, extensions, cmd_active): +def set_interface_arguments(interface_mode, extensions, bool_active): modes = ["default", "notebook", "chat", "cai_chat"] cmd_list = vars(shared.args) - cmd_list = [k for k in cmd_list if type(cmd_list[k]) is bool and k not in modes] + bool_list = [k for k in cmd_list if type(cmd_list[k]) is bool and k not in modes] + #int_list = [k for k in cmd_list if type(k) is int] shared.args.extensions = extensions for k in modes[1:]: @@ -228,9 +229,9 @@ def set_interface_arguments(interface_mode, extensions, cmd_active): if interface_mode != "default": exec(f"shared.args.{interface_mode} = True") - for k in cmd_list: + for k in bool_list: exec(f"shared.args.{k} = False") - for k in cmd_active: + for k in bool_active: exec(f"shared.args.{k} = True") shared.need_restart = True @@ -483,16 +484,17 @@ def create_interface(): current_mode = mode break cmd_list = vars(shared.args) - cmd_list = [k for k in cmd_list if type(cmd_list[k]) is bool and k not in modes] - active_cmd_list = [k for k in cmd_list if vars(shared.args)[k]] + bool_list = [k for k in cmd_list if type(cmd_list[k]) is bool and k not in modes] + bool_active = [k for k in bool_list if vars(shared.args)[k]] + #int_list = [k for k in cmd_list if type(k) is int] gr.Markdown("*Experimental*") shared.gradio['interface_modes_menu'] = gr.Dropdown(choices=modes, value=current_mode, label="Mode") shared.gradio['extensions_menu'] = gr.CheckboxGroup(choices=get_available_extensions(), value=shared.args.extensions, label="Available extensions") - shared.gradio['cmd_arguments_menu'] = gr.CheckboxGroup(choices=cmd_list, value=active_cmd_list, label="Boolean command-line flags") + shared.gradio['bool_menu'] = gr.CheckboxGroup(choices=bool_list, value=bool_active, label="Boolean command-line flags") shared.gradio['reset_interface'] = gr.Button("Apply and restart the interface", type="primary") - shared.gradio['reset_interface'].click(set_interface_arguments, [shared.gradio[k] for k in ['interface_modes_menu', 'extensions_menu', 'cmd_arguments_menu']], None) + shared.gradio['reset_interface'].click(set_interface_arguments, [shared.gradio[k] for k in ['interface_modes_menu', 'extensions_menu', 'bool_menu']], None) shared.gradio['reset_interface'].click(lambda : None, None, None, _js='() => {document.body.innerHTML=\'