Make "Show controls" customizable through settings.yaml
This commit is contained in:
parent
2a29208224
commit
73d9befb65
7 changed files with 10 additions and 7 deletions
|
|
@ -29,6 +29,7 @@ session_is_loading = False
|
|||
# UI defaults
|
||||
settings = {
|
||||
'dark_theme': True,
|
||||
'show_controls': True,
|
||||
'start_with': '',
|
||||
'mode': 'chat',
|
||||
'chat_style': 'TheEncrypted777',
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
||||
|
|
|
|||
|
|
@ -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)}}')
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue