diff --git a/README.md b/README.md index 45ab48eb..9fe4fcd4 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Its goal is to become the [AUTOMATIC1111/stable-diffusion-webui](https://github. - Multiple sampling parameters and generation options for sophisticated text generation control. - Switch between different models in the UI without restarting. - Automatic GPU layers for GGUF models (on NVIDIA GPUs). -- Free-form text generation in the Default/Notebook tabs without being limited to chat turns. +- Free-form text generation in the Notebook tab without being limited to chat turns. - OpenAI-compatible API with Chat and Completions endpoints, including tool-calling support – see [examples](https://github.com/oobabooga/text-generation-webui/wiki/12-%E2%80%90-OpenAI-API#examples). - Extension support, with numerous built-in and user-contributed extensions available. See the [wiki](https://github.com/oobabooga/text-generation-webui/wiki/07-%E2%80%90-Extensions) and [extensions directory](https://github.com/oobabooga/text-generation-webui-extensions) for details. diff --git a/css/main.css b/css/main.css index 13105bf0..ee50ac6a 100644 --- a/css/main.css +++ b/css/main.css @@ -97,11 +97,11 @@ ol li p, ul li p { display: inline-block; } -#chat-tab, #default-tab, #notebook-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab, #character-tab { +#notebook-parent-tab, #chat-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab, #character-tab { border: 0; } -#default-tab, #notebook-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab, #character-tab { +#notebook-parent-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab, #character-tab { padding: 1rem; } diff --git a/modules/shared.py b/modules/shared.py index 9efc8daf..4c9e34a7 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -202,7 +202,6 @@ settings = { 'chat-instruct_command': 'Continue the chat dialogue below. Write a single reply for the character "<|character|>".\n\n<|prompt|>', 'enable_web_search': False, 'web_search_pages': 3, - 'prompt-default': 'QA', 'prompt-notebook': 'QA', 'preset': 'Qwen3 - Thinking' if Path('user_data/presets/Qwen3 - Thinking.yaml').exists() else None, 'max_new_tokens': 512, @@ -223,6 +222,7 @@ settings = { 'custom_token_bans': '', 'negative_prompt': '', 'dark_theme': True, + 'show_two_notebook_columns': False, 'paste_to_attachment': False, 'include_past_attachments': True, diff --git a/modules/ui.py b/modules/ui.py index 57a1c383..0e8afa8f 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -274,6 +274,7 @@ def list_interface_input_elements(): # Other elements elements += [ + 'show_two_notebook_columns', 'paste_to_attachment', 'include_past_attachments', ] @@ -326,8 +327,7 @@ def save_settings(state, preset, extensions_list, show_controls, theme_state, ma output[k] = state[k] output['preset'] = preset - output['prompt-default'] = state['prompt_menu-default'] - output['prompt-notebook'] = state['prompt_menu-notebook'] + output['prompt-notebook'] = state['prompt_menu-default'] if state['show_two_notebook_columns'] else state['prompt_menu-notebook'] output['character'] = state['character_menu'] output['seed'] = int(output['seed']) output['show_controls'] = show_controls @@ -505,6 +505,7 @@ def setup_auto_save(): # Session tab (ui_session.py) 'show_controls', 'theme_state', + 'show_two_notebook_columns', 'paste_to_attachment', 'include_past_attachments' ] diff --git a/modules/ui_default.py b/modules/ui_default.py index 8acc4b10..e6d2f92d 100644 --- a/modules/ui_default.py +++ b/modules/ui_default.py @@ -15,11 +15,11 @@ outputs = ('output_textbox', 'html-default') def create_ui(): mu = shared.args.multi_user - with gr.Tab('Default', elem_id='default-tab'): + with gr.Row(visible=shared.settings['show_two_notebook_columns']) as shared.gradio['default-tab']: with gr.Row(): with gr.Column(): with gr.Row(): - shared.gradio['textbox-default'] = gr.Textbox(value=load_prompt(shared.settings['prompt-default']), lines=27, label='Input', elem_classes=['textbox_default', 'add_scrollbar']) + shared.gradio['textbox-default'] = gr.Textbox(value=load_prompt(shared.settings['prompt-notebook']), lines=27, label='Input', elem_classes=['textbox_default', 'add_scrollbar']) shared.gradio['token-counter-default'] = gr.HTML(value="0", elem_id="default-token-counter") with gr.Row(): @@ -28,7 +28,7 @@ def create_ui(): shared.gradio['Generate-default'] = gr.Button('Generate', variant='primary') with gr.Row(): - shared.gradio['prompt_menu-default'] = gr.Dropdown(choices=utils.get_available_prompts(), value=shared.settings['prompt-default'], label='Prompt', elem_classes='slim-dropdown') + shared.gradio['prompt_menu-default'] = gr.Dropdown(choices=utils.get_available_prompts(), value=shared.settings['prompt-notebook'], 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', 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) diff --git a/modules/ui_notebook.py b/modules/ui_notebook.py index 3f79a93c..e6b87342 100644 --- a/modules/ui_notebook.py +++ b/modules/ui_notebook.py @@ -16,7 +16,7 @@ outputs = ('textbox-notebook', 'html-notebook') def create_ui(): mu = shared.args.multi_user - with gr.Tab('Notebook', elem_id='notebook-tab'): + with gr.Row(visible=not shared.settings['show_two_notebook_columns']) as shared.gradio['notebook-tab']: shared.gradio['last_input-notebook'] = gr.State('') with gr.Row(): with gr.Column(scale=4): diff --git a/modules/ui_session.py b/modules/ui_session.py index dc7ca2fb..c0a34228 100644 --- a/modules/ui_session.py +++ b/modules/ui_session.py @@ -11,6 +11,7 @@ def create_ui(): with gr.Column(): gr.Markdown("## Settings") shared.gradio['toggle_dark_mode'] = gr.Button('Toggle light/dark theme 💡', elem_classes='refresh-button') + shared.gradio['show_two_notebook_columns'] = gr.Checkbox(label='Show two columns in the Notebook tab', value=shared.settings['show_two_notebook_columns']) shared.gradio['paste_to_attachment'] = gr.Checkbox(label='Turn long pasted text into attachments in the Chat tab', value=shared.settings['paste_to_attachment'], elem_id='paste_to_attachment') shared.gradio['include_past_attachments'] = gr.Checkbox(label='Include attachments/search results from previous messages in the chat prompt', value=shared.settings['include_past_attachments']) @@ -34,6 +35,12 @@ def create_ui(): lambda x: 'dark' if x == 'light' else 'light', gradio('theme_state'), gradio('theme_state')).then( None, None, None, js=f'() => {{{ui.dark_theme_js}; toggleDarkMode(); localStorage.setItem("theme", document.body.classList.contains("dark") ? "dark" : "light")}}') + shared.gradio['show_two_notebook_columns'].change( + handle_default_to_notebook_change, + gradio('show_two_notebook_columns', 'textbox-default', 'output_textbox', 'prompt_menu-default', 'textbox-notebook', 'prompt_menu-notebook'), + gradio('default-tab', 'notebook-tab', 'textbox-default', 'output_textbox', 'prompt_menu-default', 'textbox-notebook', 'prompt_menu-notebook') + ) + # Reset interface event shared.gradio['reset_interface'].click( set_interface_arguments, gradio('extensions_menu', 'bool_menu'), None).then( @@ -50,6 +57,31 @@ def handle_save_settings(state, preset, extensions, show_controls, theme): ] +def handle_default_to_notebook_change(show_two_columns, default_input, default_output, default_prompt, notebook_input, notebook_prompt): + if show_two_columns: + # Notebook to default + return [ + gr.update(visible=True), + gr.update(visible=False), + notebook_input, + notebook_input, + gr.update(value=notebook_prompt, choices=utils.get_available_prompts()), + gr.update(), + gr.update(), + ] + else: + # Default to notebook + return [ + gr.update(visible=False), + gr.update(visible=True), + gr.update(), + gr.update(), + gr.update(), + default_input, + gr.update(value=default_prompt, choices=utils.get_available_prompts()) + ] + + def set_interface_arguments(extensions, bool_active): shared.args.extensions = extensions diff --git a/server.py b/server.py index b28d30bc..16f6888b 100644 --- a/server.py +++ b/server.py @@ -145,8 +145,9 @@ def create_interface(): # Text Generation tab ui_chat.create_ui() - ui_default.create_ui() - ui_notebook.create_ui() + with gr.Tab("Notebook", elem_id='notebook-parent-tab'): + ui_default.create_ui() + ui_notebook.create_ui() ui_parameters.create_ui() # Parameters tab ui_chat.create_character_settings_ui() # Character tab