Add "save defaults to settings.yaml" button (#3574)

This commit is contained in:
oobabooga 2023-08-14 11:46:07 -03:00 committed by GitHub
parent a95e6f02cb
commit 619cb4e78b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 82 additions and 52 deletions

View file

@ -9,8 +9,10 @@ def create_ui():
with gr.Tab("Session", elem_id="session-tab"):
with gr.Row():
with gr.Column():
shared.gradio['reset_interface'] = gr.Button("Apply and restart")
shared.gradio['toggle_dark_mode'] = gr.Button('Toggle 💡')
shared.gradio['reset_interface'] = gr.Button("Apply flags/extensions and restart")
with gr.Row():
shared.gradio['toggle_dark_mode'] = gr.Button('Toggle 💡')
shared.gradio['save_settings'] = gr.Button('Save UI defaults to settings.yaml')
with gr.Row():
with gr.Column():
@ -37,6 +39,12 @@ def create_ui():
lambda: None, None, None, _js='() => {document.body.innerHTML=\'<h1 style="font-family:monospace;padding-top:20%;margin:0;height:100vh;color:lightgray;text-align:center;background:var(--body-background-fill)">Reloading...</h1>\'; setTimeout(function(){location.reload()},2500); return []}')
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(
lambda: './', None, gradio('save_root')).then(
lambda: 'settings.yaml', None, gradio('save_filename')).then(
lambda: gr.update(visible=True), None, gradio('file_saver'))
def set_interface_arguments(extensions, bool_active):