mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-02-07 08:14:24 +01:00
Merge the Default and Notebook tabs into a single Notebook tab (#7078)
This commit is contained in:
parent
db67d69ddc
commit
de24b3bb31
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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="<span>0</span>", 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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue