From 4ca82a4df9c34fc0ff429a9c7403698d89d7021d Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 9 Jan 2024 04:20:10 -0800 Subject: [PATCH] Save light/dark theme on "Save UI defaults to settings.yaml" --- modules/ui.py | 3 ++- modules/ui_session.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/ui.py b/modules/ui.py index d70b1953..efb53bdf 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -209,7 +209,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, extensions_list, show_controls): +def save_settings(state, preset, extensions_list, show_controls, theme_state): output = copy.deepcopy(shared.settings) exclude = ['name2', 'greeting', 'context', 'turn_template'] for k in state: @@ -223,6 +223,7 @@ def save_settings(state, preset, extensions_list, show_controls): output['default_extensions'] = extensions_list output['seed'] = int(output['seed']) output['show_controls'] = show_controls + output['dark_theme'] = True if theme_state == 'dark' else False # Save extension values in the UI for extension_name in extensions_list: diff --git a/modules/ui_session.py b/modules/ui_session.py index 61e05065..989046ea 100644 --- a/modules/ui_session.py +++ b/modules/ui_session.py @@ -26,6 +26,7 @@ def create_ui(): extension_name = gr.Textbox(lines=1, label='Install or update an extension', info='Enter the GitHub URL below and press Enter. For a list of extensions, see: https://github.com/oobabooga/text-generation-webui-extensions ⚠️ WARNING ⚠️ : extensions can execute arbitrary code. Make sure to inspect their source code before activating them.', interactive=not mu) extension_status = gr.Markdown() + shared.gradio['theme_state'] = gr.Textbox(visible=False, value='dark' if shared.settings['dark_theme'] else 'light') extension_name.submit(clone_or_pull_repository, extension_name, extension_status, show_progress=False) # Reset interface event @@ -33,10 +34,13 @@ def create_ui(): set_interface_arguments, gradio('extensions_menu', 'bool_menu'), None).then( lambda: None, None, None, _js='() => {document.body.innerHTML=\'