import gradio as gr from modules import shared, ui, utils from modules.github import clone_or_pull_repository from modules.utils import gradio def create_ui(): with gr.Tab("Session", elem_id="session-tab"): with gr.Row(): with gr.Column(): 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(): shared.gradio['extensions_menu'] = gr.CheckboxGroup(choices=utils.get_available_extensions(), value=shared.args.extensions, label="Available extensions", info='Note that some of these extensions may require manually installing Python requirements through the command: pip install -r extensions/extension_name/requirements.txt', elem_classes='checkboxgroup-table') with gr.Column(): shared.gradio['bool_menu'] = gr.CheckboxGroup(choices=get_boolean_arguments(), value=get_boolean_arguments(active=True), label="Boolean command-line flags", elem_classes='checkboxgroup-table') with gr.Column(): if not shared.args.multi_user: shared.gradio['save_session'] = gr.Button('Save session') shared.gradio['load_session'] = gr.File(type='binary', file_types=['.json'], label="Upload Session JSON") 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.') extension_status = gr.Markdown() extension_name.submit( clone_or_pull_repository, extension_name, extension_status, show_progress=False).then( lambda: gr.update(choices=utils.get_available_extensions(), value=shared.args.extensions), None, gradio('extensions_menu')) # Reset interface event shared.gradio['reset_interface'].click( set_interface_arguments, gradio('extensions_menu', 'bool_menu'), None).then( lambda: None, None, None, _js='() => {document.body.innerHTML=\'