diff --git a/css/main.css b/css/main.css index e82a8c61..0305efb4 100644 --- a/css/main.css +++ b/css/main.css @@ -273,7 +273,6 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { height: calc(100dvh - 200px); } - #show-controls { position: absolute; background-color: transparent; diff --git a/modules/shared.py b/modules/shared.py index fa1a0a3b..88aa8cf2 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -29,6 +29,7 @@ session_is_loading = False # UI defaults settings = { 'dark_theme': True, + 'show_controls': True, 'start_with': '', 'mode': 'chat', 'chat_style': 'TheEncrypted777', diff --git a/modules/ui.py b/modules/ui.py index 94bfe4a6..a99af375 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -178,7 +178,7 @@ def apply_interface_values(state, use_persistent=False): return [state[k] if k in state else gr.update() for k in elements] -def save_settings(state, preset, instruction_template, extensions): +def save_settings(state, preset, instruction_template, extensions, show_controls): output = copy.deepcopy(shared.settings) exclude = ['name1', 'name2', 'greeting', 'context', 'turn_template'] for k in state: @@ -192,6 +192,7 @@ def save_settings(state, preset, instruction_template, extensions): output['instruction_template'] = instruction_template output['default_extensions'] = extensions output['seed'] = int(output['seed']) + output['show_controls'] = show_controls return yaml.dump(output, sort_keys=False, width=float("inf")) diff --git a/modules/ui_chat.py b/modules/ui_chat.py index aec7a2ad..b356f8c6 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -22,9 +22,9 @@ def create_ui(): with gr.Tab('Chat', elem_id='chat-tab'): shared.gradio['display'] = gr.HTML(value=chat_html_wrapper({'internal': [], 'visible': []}, shared.settings['name1'], shared.settings['name2'], 'chat', 'cai-chat')) - shared.gradio['textbox'] = gr.Textbox(label='Input', elem_id='chat-input') - shared.gradio['show-controls'] = gr.Checkbox(value=True, label='Show controls', elem_id='show-controls') + shared.gradio['show_controls'] = gr.Checkbox(value=shared.settings['show_controls'], label='Show controls', elem_id='show-controls') + with gr.Row(): shared.gradio['Stop'] = gr.Button('Stop', elem_id='stop') shared.gradio['Generate'] = gr.Button('Generate', elem_id='Generate', variant='primary') @@ -127,8 +127,6 @@ def create_event_handlers(): shared.input_params = gradio(inputs) shared.reload_inputs = gradio(reload_arr) - shared.gradio['show-controls'].change(None, gradio('show-controls'), None, _js=f'(x) => {{{ui.show_controls_js}; toggle_controls(x)}}') - shared.gradio['Generate'].click( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( lambda x: (x, ''), gradio('textbox'), gradio('Chat input', 'textbox'), show_progress=False).then( @@ -276,3 +274,5 @@ def create_event_handlers(): shared.gradio['send_instruction_to_negative_prompt'].click( prompts.load_instruction_prompt_simple, gradio('instruction_template'), gradio('negative_prompt')).then( lambda: None, None, None, _js=f'() => {{{ui.switch_tabs_js}; switch_to_generation_parameters()}}') + + shared.gradio['show_controls'].change(None, gradio('show_controls'), None, _js=f'(x) => {{{ui.show_controls_js}; toggle_controls(x)}}') diff --git a/modules/ui_session.py b/modules/ui_session.py index b774a207..537a31f2 100644 --- a/modules/ui_session.py +++ b/modules/ui_session.py @@ -41,7 +41,7 @@ def create_ui(): shared.gradio['toggle_dark_mode'].click(lambda: None, None, None, _js='() => {document.getElementsByTagName("body")[0].classList.toggle("dark")}') shared.gradio['save_settings'].click( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( - ui.save_settings, gradio('interface_state', 'preset_menu', 'instruction_template', 'extensions_menu'), gradio('save_contents')).then( + ui.save_settings, gradio('interface_state', 'preset_menu', 'instruction_template', 'extensions_menu', 'show_controls'), gradio('save_contents')).then( lambda: './', None, gradio('save_root')).then( lambda: 'settings.yaml', None, gradio('save_filename')).then( lambda: gr.update(visible=True), None, gradio('file_saver')) diff --git a/server.py b/server.py index d90453a0..ef213a87 100644 --- a/server.py +++ b/server.py @@ -128,6 +128,7 @@ def create_interface(): shared.gradio['interface'].load(lambda: None, None, None, _js="() => document.getElementsByTagName('body')[0].classList.add('dark')") shared.gradio['interface'].load(lambda: None, None, None, _js=f"() => {{{js}}}") + shared.gradio['interface'].load(None, gradio('show_controls'), None, _js=f'(x) => {{{ui.show_controls_js}; toggle_controls(x)}}') shared.gradio['interface'].load(partial(ui.apply_interface_values, {}, use_persistent=True), None, gradio(ui.list_interface_input_elements()), show_progress=False) shared.gradio['interface'].load(chat.redraw_html, gradio(ui_chat.reload_arr), gradio('display')) diff --git a/settings-template.yaml b/settings-template.yaml index 11cd1185..b2526df1 100644 --- a/settings-template.yaml +++ b/settings-template.yaml @@ -1,4 +1,5 @@ dark_theme: true +show_controls: true start_with: '' mode: chat chat_style: TheEncrypted777