From 1ca54faaf0bf91472f9b8a2637b4c833a97a26d4 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 26 Sep 2023 05:44:04 -0700 Subject: [PATCH] Improve --multi-user mode --- modules/shared.py | 6 +++--- modules/training.py | 39 ++++++++++++++++++++------------------- modules/ui.py | 4 ++-- modules/ui_chat.py | 31 +++++++++++++++++-------------- modules/ui_default.py | 7 ++++--- modules/ui_file_saving.py | 9 +++++---- modules/ui_model_menu.py | 30 ++++++++++++++++-------------- modules/ui_notebook.py | 7 ++++--- modules/ui_parameters.py | 7 ++++--- modules/ui_session.py | 7 ++++--- 10 files changed, 79 insertions(+), 68 deletions(-) diff --git a/modules/shared.py b/modules/shared.py index 5eceddd1..9b36b2b7 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -200,10 +200,10 @@ if args.trust_remote_code: logger.warning("trust_remote_code is enabled. This is dangerous.") if args.share: logger.warning("The gradio \"share link\" feature uses a proprietary executable to create a reverse tunnel. Use it with care.") -if args.multi_user: - logger.warning("The multi-user mode is highly experimental. DO NOT EXPOSE IT TO THE INTERNET.") if any((args.listen, args.share)) and not any((args.gradio_auth, args.gradio_auth_path)): - logger.warning("\nYou are potentially exposing the web UI to the internet without any access password.\nYou can create one with the \"--gradio-auth\" flag like this: --gradio-auth username:password (replace username:password with your own).") + logger.warning("\nYou are potentially exposing the web UI to the entire internet without any access password.\nYou can create one with the \"--gradio-auth\" flag like this:\n\n--gradio-auth username:password\n\nMake sure to replace username:password with your own.") + if args.multi_user: + logger.warning("\nThe multi-user mode is highly experimental and should not be shared publicly.") def fix_loader_name(name): diff --git a/modules/training.py b/modules/training.py index 30446900..12aa1733 100644 --- a/modules/training.py +++ b/modules/training.py @@ -49,6 +49,7 @@ train_template = {} def create_ui(): + mu = shared.args.multi_user with gr.Tab("Training", elem_id="training-tab"): with gr.Tab('Train LoRA', elem_id='lora-train-tab'): tmp = gr.State('') @@ -57,8 +58,8 @@ def create_ui(): gr.Markdown("[Tutorial](https://github.com/oobabooga/text-generation-webui/blob/main/docs/Training-LoRAs.md)") with gr.Row(): - copy_from = gr.Dropdown(label='Copy parameters from', value='None', choices=utils.get_available_loras(), elem_classes=['slim-dropdown']) - ui.create_refresh_button(copy_from, lambda: None, lambda: {'choices': utils.get_available_loras()}, 'refresh-button') + copy_from = gr.Dropdown(label='Copy parameters from', value='None', choices=utils.get_available_loras(), elem_classes=['slim-dropdown'], interactive=not mu) + ui.create_refresh_button(copy_from, lambda: None, lambda: {'choices': utils.get_available_loras()}, 'refresh-button', interactive=not mu) with gr.Row(): with gr.Column(scale=5): @@ -100,23 +101,23 @@ def create_ui(): with gr.Column(): with gr.Tab(label='Formatted Dataset'): with gr.Row(): - format = gr.Dropdown(choices=utils.get_datasets('training/formats', 'json'), value='None', label='Data Format', info='The format file used to decide how to format the dataset input.', elem_classes=['slim-dropdown']) - ui.create_refresh_button(format, lambda: None, lambda: {'choices': utils.get_datasets('training/formats', 'json')}, 'refresh-button') + format = gr.Dropdown(choices=utils.get_datasets('training/formats', 'json'), value='None', label='Data Format', info='The format file used to decide how to format the dataset input.', elem_classes=['slim-dropdown'], interactive=not mu) + ui.create_refresh_button(format, lambda: None, lambda: {'choices': utils.get_datasets('training/formats', 'json')}, 'refresh-button', interactive=not mu) with gr.Row(): - dataset = gr.Dropdown(choices=utils.get_datasets('training/datasets', 'json'), value='None', label='Dataset', info='The dataset file to use for training.', elem_classes=['slim-dropdown']) - ui.create_refresh_button(dataset, lambda: None, lambda: {'choices': utils.get_datasets('training/datasets', 'json')}, 'refresh-button') + dataset = gr.Dropdown(choices=utils.get_datasets('training/datasets', 'json'), value='None', label='Dataset', info='The dataset file to use for training.', elem_classes=['slim-dropdown'], interactive=not mu) + ui.create_refresh_button(dataset, lambda: None, lambda: {'choices': utils.get_datasets('training/datasets', 'json')}, 'refresh-button', interactive=not mu) with gr.Row(): - eval_dataset = gr.Dropdown(choices=utils.get_datasets('training/datasets', 'json'), value='None', label='Evaluation Dataset', info='The (optional) dataset file used to evaluate the model after training.', elem_classes=['slim-dropdown']) - ui.create_refresh_button(eval_dataset, lambda: None, lambda: {'choices': utils.get_datasets('training/datasets', 'json')}, 'refresh-button') + eval_dataset = gr.Dropdown(choices=utils.get_datasets('training/datasets', 'json'), value='None', label='Evaluation Dataset', info='The (optional) dataset file used to evaluate the model after training.', elem_classes=['slim-dropdown'], interactive=not mu) + ui.create_refresh_button(eval_dataset, lambda: None, lambda: {'choices': utils.get_datasets('training/datasets', 'json')}, 'refresh-button', interactive=not mu) eval_steps = gr.Number(label='Evaluate every n steps', value=100, info='If an evaluation dataset is given, test it every time this many steps pass.') with gr.Tab(label="Raw text file"): with gr.Row(): - raw_text_file = gr.Dropdown(choices=utils.get_datasets('training/datasets', 'txt'), value='None', label='Text file', info='The raw text file to use for training.', elem_classes=['slim-dropdown']) - ui.create_refresh_button(raw_text_file, lambda: None, lambda: {'choices': utils.get_datasets('training/datasets', 'txt')}, 'refresh-button') + raw_text_file = gr.Dropdown(choices=utils.get_datasets('training/datasets', 'txt'), value='None', label='Text file', info='The raw text file to use for training.', elem_classes=['slim-dropdown'], interactive=not mu) + ui.create_refresh_button(raw_text_file, lambda: None, lambda: {'choices': utils.get_datasets('training/datasets', 'txt')}, 'refresh-button', interactive=not mu) with gr.Row(): with gr.Column(): @@ -128,16 +129,16 @@ def create_ui(): min_chars = gr.Number(label='Ignore small blocks', value=0, info='Ignore Hard Cut blocks that have less or equal characters than this number') with gr.Row(): - start_button = gr.Button("Start LoRA Training", variant='primary') - stop_button = gr.Button("Interrupt") + start_button = gr.Button("Start LoRA Training", variant='primary', interactive=not mu) + stop_button = gr.Button("Interrupt", interactive=not mu) output = gr.Markdown(value="Ready") with gr.Tab('Perplexity evaluation', elem_id='evaluate-tab'): with gr.Row(): with gr.Column(): - models = gr.Dropdown(utils.get_available_models(), label='Models', multiselect=True) - evaluate_text_file = gr.Dropdown(choices=['wikitext', 'ptb', 'ptb_new'] + utils.get_datasets('training/datasets', 'txt')[1:], value='wikitext', label='Input dataset', info='The raw text file on which the model will be evaluated. The first options are automatically downloaded: wikitext, ptb, and ptb_new. The next options are your local text files under training/datasets.') + models = gr.Dropdown(utils.get_available_models(), label='Models', multiselect=True, interactive=not mu) + evaluate_text_file = gr.Dropdown(choices=['wikitext', 'ptb', 'ptb_new'] + utils.get_datasets('training/datasets', 'txt')[1:], value='wikitext', label='Input dataset', info='The raw text file on which the model will be evaluated. The first options are automatically downloaded: wikitext, ptb, and ptb_new. The next options are your local text files under training/datasets.', interactive=not mu) with gr.Row(): with gr.Column(): stride_length = gr.Slider(label='Stride', minimum=1, maximum=2048, value=512, step=1, info='Used to make the evaluation faster at the cost of accuracy. 1 = slowest but most accurate. 512 is a common value.') @@ -146,17 +147,17 @@ def create_ui(): max_length = gr.Slider(label='max_length', minimum=0, maximum=8096, value=0, step=1, info='The context for each evaluation. If set to 0, the maximum context length for the model will be used.') with gr.Row(): - start_current_evaluation = gr.Button("Evaluate loaded model") - start_evaluation = gr.Button("Evaluate selected models") - stop_evaluation = gr.Button("Interrupt") + start_current_evaluation = gr.Button("Evaluate loaded model", interactive=not mu) + start_evaluation = gr.Button("Evaluate selected models", interactive=not mu) + stop_evaluation = gr.Button("Interrupt", interactive=not mu) with gr.Column(): evaluation_log = gr.Markdown(value='') evaluation_table = gr.Dataframe(value=generate_markdown_table(), interactive=True) with gr.Row(): - save_comments = gr.Button('Save comments', elem_classes="small-button") - refresh_table = gr.Button('Refresh the table', elem_classes="small-button") + save_comments = gr.Button('Save comments', elem_classes="small-button", interactive=not mu) + refresh_table = gr.Button('Refresh the table', elem_classes="small-button", interactive=not mu) # Training events all_params = [lora_name, always_override, save_steps, micro_batch_size, batch_size, epochs, learning_rate, lr_scheduler_type, lora_rank, lora_alpha, lora_dropout, cutoff_len, dataset, eval_dataset, format, eval_steps, raw_text_file, overlap_len, newline_favor_len, higher_rank_limit, warmup_steps, optimizer, hard_cut_string, train_only_after, stop_at_loss, add_eos_token, min_chars, report_to] diff --git a/modules/ui.py b/modules/ui.py index 823d5d0f..e4654081 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -219,7 +219,7 @@ class ToolButton(gr.Button, gr.components.IOComponent): return "button" -def create_refresh_button(refresh_component, refresh_method, refreshed_args, elem_class): +def create_refresh_button(refresh_component, refresh_method, refreshed_args, elem_class, interactive=True): """ Copied from https://github.com/AUTOMATIC1111/stable-diffusion-webui """ @@ -232,7 +232,7 @@ def create_refresh_button(refresh_component, refresh_method, refreshed_args, ele return gr.update(**(args or {})) - refresh_button = ToolButton(value=refresh_symbol, elem_classes=elem_class) + refresh_button = ToolButton(value=refresh_symbol, elem_classes=elem_class, interactive=interactive) refresh_button.click( fn=refresh, inputs=[], diff --git a/modules/ui_chat.py b/modules/ui_chat.py index 4ec93ecb..88257989 100644 --- a/modules/ui_chat.py +++ b/modules/ui_chat.py @@ -16,6 +16,8 @@ clear_arr = ('delete_chat-confirm', 'delete_chat', 'delete_chat-cancel') def create_ui(): + mu = shared.args.multi_user + shared.gradio['Chat input'] = gr.State() shared.gradio['dummy'] = gr.State() shared.gradio['history'] = gr.State({'internal': [], 'visible': []}) @@ -63,9 +65,9 @@ def create_ui(): shared.gradio['send-chat-to-notebook'] = gr.Button('Send to notebook') with gr.Row(elem_id='past-chats-row'): - shared.gradio['unique_id'] = gr.Dropdown(label='Past chats', elem_classes=['slim-dropdown']) - shared.gradio['rename_chat'] = gr.Button('Rename', elem_classes='refresh-button') - shared.gradio['delete_chat'] = gr.Button('🗑️', elem_classes='refresh-button') + shared.gradio['unique_id'] = gr.Dropdown(label='Past chats', elem_classes=['slim-dropdown'], interactive=not mu) + shared.gradio['rename_chat'] = gr.Button('Rename', elem_classes='refresh-button', interactive=not mu) + shared.gradio['delete_chat'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu) shared.gradio['delete_chat-cancel'] = gr.Button('Cancel', visible=False, elem_classes='refresh-button') shared.gradio['delete_chat-confirm'] = gr.Button('Confirm', variant='stop', visible=False, elem_classes='refresh-button') @@ -83,14 +85,15 @@ def create_ui(): def create_chat_settings_ui(): + mu = shared.args.multi_user with gr.Tab('Character'): with gr.Row(): with gr.Column(scale=8): with gr.Row(): shared.gradio['character_menu'] = gr.Dropdown(value='', choices=utils.get_available_characters(), label='Character', elem_id='character-menu', info='Used in chat and chat-instruct modes.', elem_classes='slim-dropdown') - ui.create_refresh_button(shared.gradio['character_menu'], lambda: None, lambda: {'choices': utils.get_available_characters()}, 'refresh-button') - shared.gradio['save_character'] = gr.Button('💾', elem_classes='refresh-button') - shared.gradio['delete_character'] = gr.Button('🗑️', elem_classes='refresh-button') + ui.create_refresh_button(shared.gradio['character_menu'], lambda: None, lambda: {'choices': utils.get_available_characters()}, 'refresh-button', interactive=not mu) + shared.gradio['save_character'] = gr.Button('💾', elem_classes='refresh-button', interactive=not mu) + shared.gradio['delete_character'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu) shared.gradio['name1'] = gr.Textbox(value=shared.settings['name1'], lines=1, label='Your name') shared.gradio['name2'] = gr.Textbox(value='', lines=1, label='Character\'s name') @@ -98,16 +101,16 @@ def create_chat_settings_ui(): shared.gradio['greeting'] = gr.Textbox(value='', lines=5, label='Greeting', elem_classes=['add_scrollbar']) with gr.Column(scale=1): - shared.gradio['character_picture'] = gr.Image(label='Character picture', type='pil') - shared.gradio['your_picture'] = gr.Image(label='Your picture', type='pil', value=Image.open(Path('cache/pfp_me.png')) if Path('cache/pfp_me.png').exists() else None) + shared.gradio['character_picture'] = gr.Image(label='Character picture', type='pil', interactive=not mu) + shared.gradio['your_picture'] = gr.Image(label='Your picture', type='pil', value=Image.open(Path('cache/pfp_me.png')) if Path('cache/pfp_me.png').exists() else None, interactive=not mu) with gr.Tab('Instruction template'): with gr.Row(): with gr.Row(): shared.gradio['instruction_template'] = gr.Dropdown(choices=utils.get_available_instruction_templates(), label='Instruction template', value='None', info='Change this according to the model/LoRA that you are using. Used in instruct and chat-instruct modes.', elem_classes='slim-dropdown') - ui.create_refresh_button(shared.gradio['instruction_template'], lambda: None, lambda: {'choices': utils.get_available_instruction_templates()}, 'refresh-button') - shared.gradio['save_template'] = gr.Button('💾', elem_classes='refresh-button') - shared.gradio['delete_template'] = gr.Button('🗑️ ', elem_classes='refresh-button') + ui.create_refresh_button(shared.gradio['instruction_template'], lambda: None, lambda: {'choices': utils.get_available_instruction_templates()}, 'refresh-button', interactive=not mu) + shared.gradio['save_template'] = gr.Button('💾', elem_classes='refresh-button', interactive=not mu) + shared.gradio['delete_template'] = gr.Button('🗑️ ', elem_classes='refresh-button', interactive=not mu) shared.gradio['name1_instruct'] = gr.Textbox(value='', lines=2, label='User string') shared.gradio['name2_instruct'] = gr.Textbox(value='', lines=1, label='Bot string') @@ -132,15 +135,15 @@ def create_chat_settings_ui(): with gr.Tab('Upload character'): with gr.Tab('YAML or JSON'): with gr.Row(): - shared.gradio['upload_json'] = gr.File(type='binary', file_types=['.json', '.yaml'], label='JSON or YAML File') - shared.gradio['upload_img_bot'] = gr.Image(type='pil', label='Profile Picture (optional)') + shared.gradio['upload_json'] = gr.File(type='binary', file_types=['.json', '.yaml'], label='JSON or YAML File', interactive=not mu) + shared.gradio['upload_img_bot'] = gr.Image(type='pil', label='Profile Picture (optional)', interactive=not mu) shared.gradio['Submit character'] = gr.Button(value='Submit', interactive=False) with gr.Tab('TavernAI PNG'): with gr.Row(): with gr.Column(): - shared.gradio['upload_img_tavern'] = gr.Image(type='pil', label='TavernAI PNG File', elem_id='upload_img_tavern') + shared.gradio['upload_img_tavern'] = gr.Image(type='pil', label='TavernAI PNG File', elem_id='upload_img_tavern', interactive=not mu) shared.gradio['tavern_json'] = gr.State() with gr.Column(): shared.gradio['tavern_name'] = gr.Textbox(value='', lines=1, label='Name', interactive=False) diff --git a/modules/ui_default.py b/modules/ui_default.py index 7357094b..7db6f0d9 100644 --- a/modules/ui_default.py +++ b/modules/ui_default.py @@ -14,6 +14,7 @@ outputs = ('output_textbox', 'html-default') def create_ui(): + mu = shared.args.multi_user with gr.Tab('Default', elem_id='default-tab'): shared.gradio['last_input-default'] = gr.State('') with gr.Row(): @@ -29,9 +30,9 @@ def create_ui(): with gr.Row(): shared.gradio['prompt_menu-default'] = gr.Dropdown(choices=utils.get_available_prompts(), value='None', label='Prompt', elem_classes='slim-dropdown') - ui.create_refresh_button(shared.gradio['prompt_menu-default'], lambda: None, lambda: {'choices': utils.get_available_prompts()}, 'refresh-button') - shared.gradio['save_prompt-default'] = gr.Button('💾', elem_classes='refresh-button') - shared.gradio['delete_prompt-default'] = gr.Button('🗑️', elem_classes='refresh-button') + ui.create_refresh_button(shared.gradio['prompt_menu-default'], lambda: None, lambda: {'choices': utils.get_available_prompts()}, 'refresh-button', interactive=not mu) + shared.gradio['save_prompt-default'] = gr.Button('💾', elem_classes='refresh-button', interactive=not mu) + shared.gradio['delete_prompt-default'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu) with gr.Column(): with gr.Tab('Raw'): diff --git a/modules/ui_file_saving.py b/modules/ui_file_saving.py index 1ba8e4bb..7357ac85 100644 --- a/modules/ui_file_saving.py +++ b/modules/ui_file_saving.py @@ -5,6 +5,7 @@ from modules.utils import gradio def create_ui(): + mu = shared.args.multi_user # Text file saver with gr.Box(visible=False, elem_classes='file-saver') as shared.gradio['file_saver']: @@ -12,7 +13,7 @@ def create_ui(): shared.gradio['save_root'] = gr.Textbox(lines=1, label='File folder', info='For reference. Unchangeable.', interactive=False) shared.gradio['save_contents'] = gr.Textbox(lines=10, label='File contents') with gr.Row(): - shared.gradio['save_confirm'] = gr.Button('Save', elem_classes="small-button") + shared.gradio['save_confirm'] = gr.Button('Save', elem_classes="small-button", interactive=not mu) shared.gradio['save_cancel'] = gr.Button('Cancel', elem_classes="small-button") # Text file deleter @@ -20,20 +21,20 @@ def create_ui(): shared.gradio['delete_filename'] = gr.Textbox(lines=1, label='File name') shared.gradio['delete_root'] = gr.Textbox(lines=1, label='File folder', info='For reference. Unchangeable.', interactive=False) with gr.Row(): - shared.gradio['delete_confirm'] = gr.Button('Delete', elem_classes="small-button", variant='stop') + shared.gradio['delete_confirm'] = gr.Button('Delete', elem_classes="small-button", variant='stop', interactive=not mu) shared.gradio['delete_cancel'] = gr.Button('Cancel', elem_classes="small-button") # Character saver/deleter with gr.Box(visible=False, elem_classes='file-saver') as shared.gradio['character_saver']: shared.gradio['save_character_filename'] = gr.Textbox(lines=1, label='File name', info='The character will be saved to your characters/ folder with this base filename.') with gr.Row(): - shared.gradio['save_character_confirm'] = gr.Button('Save', elem_classes="small-button") + shared.gradio['save_character_confirm'] = gr.Button('Save', elem_classes="small-button", interactive=not mu) shared.gradio['save_character_cancel'] = gr.Button('Cancel', elem_classes="small-button") with gr.Box(visible=False, elem_classes='file-saver') as shared.gradio['character_deleter']: gr.Markdown('Confirm the character deletion?') with gr.Row(): - shared.gradio['delete_character_confirm'] = gr.Button('Delete', elem_classes="small-button", variant='stop') + 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") diff --git a/modules/ui_model_menu.py b/modules/ui_model_menu.py index 4be48d8b..a63ad4f9 100644 --- a/modules/ui_model_menu.py +++ b/modules/ui_model_menu.py @@ -23,6 +23,8 @@ from modules.utils import gradio def create_ui(): + mu = shared.args.multi_user + # Finding the default values for the GPU and CPU memories total_mem = [] for i in range(torch.cuda.device_count()): @@ -51,18 +53,18 @@ def create_ui(): with gr.Row(): with gr.Column(): with gr.Row(): - shared.gradio['model_menu'] = gr.Dropdown(choices=utils.get_available_models(), value=shared.model_name, label='Model', elem_classes='slim-dropdown') - ui.create_refresh_button(shared.gradio['model_menu'], lambda: None, lambda: {'choices': utils.get_available_models()}, 'refresh-button') - shared.gradio['load_model'] = gr.Button("Load", visible=not shared.settings['autoload_model'], elem_classes='refresh-button') - shared.gradio['unload_model'] = gr.Button("Unload", elem_classes='refresh-button') - shared.gradio['reload_model'] = gr.Button("Reload", elem_classes='refresh-button') - shared.gradio['save_model_settings'] = gr.Button("Save settings", elem_classes='refresh-button') + shared.gradio['model_menu'] = gr.Dropdown(choices=utils.get_available_models(), value=shared.model_name, label='Model', elem_classes='slim-dropdown', interactive=not mu) + ui.create_refresh_button(shared.gradio['model_menu'], lambda: None, lambda: {'choices': utils.get_available_models()}, 'refresh-button', interactive=not mu) + shared.gradio['load_model'] = gr.Button("Load", visible=not shared.settings['autoload_model'], elem_classes='refresh-button', interactive=not mu) + shared.gradio['unload_model'] = gr.Button("Unload", elem_classes='refresh-button', interactive=not mu) + shared.gradio['reload_model'] = gr.Button("Reload", elem_classes='refresh-button', interactive=not mu) + shared.gradio['save_model_settings'] = gr.Button("Save settings", elem_classes='refresh-button', interactive=not mu) with gr.Column(): with gr.Row(): - shared.gradio['lora_menu'] = gr.Dropdown(multiselect=True, choices=utils.get_available_loras(), value=shared.lora_names, label='LoRA(s)', elem_classes='slim-dropdown') - ui.create_refresh_button(shared.gradio['lora_menu'], lambda: None, lambda: {'choices': utils.get_available_loras(), 'value': shared.lora_names}, 'refresh-button') - shared.gradio['lora_menu_apply'] = gr.Button(value='Apply LoRAs', elem_classes='refresh-button') + shared.gradio['lora_menu'] = gr.Dropdown(multiselect=True, choices=utils.get_available_loras(), value=shared.lora_names, label='LoRA(s)', elem_classes='slim-dropdown', interactive=not mu) + ui.create_refresh_button(shared.gradio['lora_menu'], lambda: None, lambda: {'choices': utils.get_available_loras(), 'value': shared.lora_names}, 'refresh-button', interactive=not mu) + shared.gradio['lora_menu_apply'] = gr.Button(value='Apply LoRAs', elem_classes='refresh-button', interactive=not mu) with gr.Row(): with gr.Column(): @@ -124,13 +126,13 @@ def create_ui(): with gr.Column(): with gr.Row(): - shared.gradio['autoload_model'] = gr.Checkbox(value=shared.settings['autoload_model'], label='Autoload the model', info='Whether to load the model as soon as it is selected in the Model dropdown.') + shared.gradio['autoload_model'] = gr.Checkbox(value=shared.settings['autoload_model'], label='Autoload the model', info='Whether to load the model as soon as it is selected in the Model dropdown.', interactive=not mu) - shared.gradio['custom_model_menu'] = gr.Textbox(label="Download model or LoRA", info="Enter the Hugging Face username/model path, for instance: facebook/galactica-125m. To specify a branch, add it at the end after a \":\" character like this: facebook/galactica-125m:main. To download a single file, enter its name in the second box.") - shared.gradio['download_specific_file'] = gr.Textbox(placeholder="File name (for GGUF models)", show_label=False, max_lines=1) + shared.gradio['custom_model_menu'] = gr.Textbox(label="Download model or LoRA", info="Enter the Hugging Face username/model path, for instance: facebook/galactica-125m. To specify a branch, add it at the end after a \":\" character like this: facebook/galactica-125m:main. To download a single file, enter its name in the second box.", interactive=not mu) + shared.gradio['download_specific_file'] = gr.Textbox(placeholder="File name (for GGUF models)", show_label=False, max_lines=1, interactive=not mu) with gr.Row(): - shared.gradio['download_model_button'] = gr.Button("Download", variant='primary') - shared.gradio['get_file_list'] = gr.Button("Get file list") + shared.gradio['download_model_button'] = gr.Button("Download", variant='primary', interactive=not mu) + shared.gradio['get_file_list'] = gr.Button("Get file list", interactive=not mu) with gr.Row(): shared.gradio['model_status'] = gr.Markdown('No model is loaded' if shared.model_name == 'None' else 'Ready') diff --git a/modules/ui_notebook.py b/modules/ui_notebook.py index 60e3ee4e..6bd5c919 100644 --- a/modules/ui_notebook.py +++ b/modules/ui_notebook.py @@ -14,6 +14,7 @@ outputs = ('textbox-notebook', 'html-notebook') def create_ui(): + mu = shared.args.multi_user with gr.Tab('Notebook', elem_id='notebook-tab'): shared.gradio['last_input-notebook'] = gr.State('') with gr.Row(): @@ -55,9 +56,9 @@ def create_ui(): gr.HTML('
') with gr.Row(): shared.gradio['prompt_menu-notebook'] = gr.Dropdown(choices=utils.get_available_prompts(), value='None', label='Prompt', elem_classes='slim-dropdown') - ui.create_refresh_button(shared.gradio['prompt_menu-notebook'], lambda: None, lambda: {'choices': utils.get_available_prompts()}, ['refresh-button', 'refresh-button-small']) - shared.gradio['save_prompt-notebook'] = gr.Button('💾', elem_classes=['refresh-button', 'refresh-button-small']) - shared.gradio['delete_prompt-notebook'] = gr.Button('🗑️', elem_classes=['refresh-button', 'refresh-button-small']) + ui.create_refresh_button(shared.gradio['prompt_menu-notebook'], lambda: None, lambda: {'choices': utils.get_available_prompts()}, ['refresh-button', 'refresh-button-small'], interactive=not mu) + shared.gradio['save_prompt-notebook'] = gr.Button('💾', elem_classes=['refresh-button', 'refresh-button-small'], interactive=not mu) + shared.gradio['delete_prompt-notebook'] = gr.Button('🗑️', elem_classes=['refresh-button', 'refresh-button-small'], interactive=not mu) def create_event_handlers(): diff --git a/modules/ui_parameters.py b/modules/ui_parameters.py index bef9b928..c7ddbb66 100644 --- a/modules/ui_parameters.py +++ b/modules/ui_parameters.py @@ -7,6 +7,7 @@ from modules.utils import gradio def create_ui(default_preset): + mu = shared.args.multi_user generate_params = presets.load_preset(default_preset) with gr.Tab("Parameters", elem_id="parameters"): with gr.Tab("Generation"): @@ -14,9 +15,9 @@ def create_ui(default_preset): with gr.Column(): with gr.Row(): shared.gradio['preset_menu'] = gr.Dropdown(choices=utils.get_available_presets(), value=default_preset, label='Preset', elem_classes='slim-dropdown') - ui.create_refresh_button(shared.gradio['preset_menu'], lambda: None, lambda: {'choices': utils.get_available_presets()}, 'refresh-button') - shared.gradio['save_preset'] = gr.Button('💾', elem_classes='refresh-button') - shared.gradio['delete_preset'] = gr.Button('🗑️', elem_classes='refresh-button') + ui.create_refresh_button(shared.gradio['preset_menu'], lambda: None, lambda: {'choices': utils.get_available_presets()}, 'refresh-button', interactive=not mu) + shared.gradio['save_preset'] = gr.Button('💾', elem_classes='refresh-button', interactive=not mu) + shared.gradio['delete_preset'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu) with gr.Column(): shared.gradio['filter_by_loader'] = gr.Dropdown(label="Filter by loader", choices=["All"] + list(loaders.loaders_and_params.keys()), value="All", elem_classes='slim-dropdown') diff --git a/modules/ui_session.py b/modules/ui_session.py index 0f96a245..13610fcd 100644 --- a/modules/ui_session.py +++ b/modules/ui_session.py @@ -6,13 +6,14 @@ from modules.utils import gradio def create_ui(): + mu = shared.args.multi_user 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") + shared.gradio['reset_interface'] = gr.Button("Apply flags/extensions and restart", interactive=not mu) with gr.Row(): shared.gradio['toggle_dark_mode'] = gr.Button('Toggle 💡') - shared.gradio['save_settings'] = gr.Button('Save UI defaults to settings.yaml') + shared.gradio['save_settings'] = gr.Button('Save UI defaults to settings.yaml', interactive=not mu) with gr.Row(): with gr.Column(): @@ -22,7 +23,7 @@ def create_ui(): 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(): - 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_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() extension_name.submit(clone_or_pull_repository, extension_name, extension_status, show_progress=False)