mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-21 23:57:58 +01:00
Refresh the Preset menu after saving a preset
This commit is contained in:
parent
83b64e7fc1
commit
47d9e2618b
@ -37,6 +37,14 @@ def create_ui():
|
||||
shared.gradio['delete_character_confirm'] = gr.Button('Delete', elem_classes="small-button", variant='stop', interactive=not mu)
|
||||
shared.gradio['delete_character_cancel'] = gr.Button('Cancel', elem_classes="small-button")
|
||||
|
||||
# Preset saver
|
||||
with gr.Group(visible=False, elem_classes='file-saver') as shared.gradio['preset_saver']:
|
||||
shared.gradio['save_preset_filename'] = gr.Textbox(lines=1, label='File name', info='The preset will be saved to your presets/ folder with this base filename.')
|
||||
shared.gradio['save_preset_contents'] = gr.Textbox(lines=10, label='File contents')
|
||||
with gr.Row():
|
||||
shared.gradio['save_preset_confirm'] = gr.Button('Save', elem_classes="small-button", variant='primary', interactive=not mu)
|
||||
shared.gradio['save_preset_cancel'] = gr.Button('Cancel', elem_classes="small-button")
|
||||
|
||||
|
||||
def create_event_handlers():
|
||||
shared.gradio['save_confirm'].click(
|
||||
@ -65,10 +73,16 @@ def create_event_handlers():
|
||||
|
||||
shared.gradio['save_preset'].click(
|
||||
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
|
||||
presets.generate_preset_yaml, gradio('interface_state'), gradio('save_contents')).then(
|
||||
lambda: 'presets/', None, gradio('save_root')).then(
|
||||
lambda: 'My Preset.yaml', None, gradio('save_filename')).then(
|
||||
lambda: gr.update(visible=True), None, gradio('file_saver'))
|
||||
presets.generate_preset_yaml, gradio('interface_state'), gradio('save_preset_contents')).then(
|
||||
lambda: 'My Preset', None, gradio('save_preset_filename')).then(
|
||||
lambda: gr.update(visible=True), None, gradio('preset_saver'))
|
||||
|
||||
shared.gradio['save_preset_confirm'].click(
|
||||
lambda x, y: utils.save_file(f'presets/{x}.yaml', y), gradio('save_preset_filename', 'save_preset_contents'), None).then(
|
||||
lambda: gr.update(visible=False), None, gradio('preset_saver')).then(
|
||||
lambda x: gr.update(choices=utils.get_available_presets(), value=x), gradio('save_preset_filename'), gradio('preset_menu'))
|
||||
|
||||
shared.gradio['save_preset_cancel'].click(lambda: gr.update(visible=False), None, gradio('preset_saver'))
|
||||
|
||||
shared.gradio['delete_preset'].click(
|
||||
lambda x: f'{x}.yaml', gradio('preset_menu'), gradio('delete_filename')).then(
|
||||
|
Loading…
Reference in New Issue
Block a user