Fix for comments in prompts with styles (#1948)

(#1862)
a fix for the 0.01% who use comments in prompts. Before this, styles could be considered part of a comment.

strips comments from prompts first, then from each applied style before merge
same process for extracting styles from prompts
updated tooltips for toolbuttons to apply styles
removed code made redundant by this change, from modules.processing_scripts.comments
This commit is contained in:
DenOfEquity
2024-09-30 11:16:55 +01:00
committed by GitHub
parent 22e2bc3bc0
commit 86d003266b
5 changed files with 32 additions and 64 deletions

View File

@@ -67,7 +67,7 @@ class UiPromptStyles:
with gr.Row():
self.selection = gr.Dropdown(label="Styles", elem_id=f"{tabname}_styles_edit_select", choices=list(shared.prompt_styles.styles), value=[], allow_custom_value=True, info="Styles allow you to add custom text to prompt. Use the {prompt} token in style text, and it will be replaced with user's prompt when applying style. Otherwise, style's text will be added to the end of the prompt.")
ui_common.create_refresh_button([self.dropdown, self.selection], shared.prompt_styles.reload, lambda: {"choices": list(shared.prompt_styles.styles)}, f"refresh_{tabname}_styles")
self.materialize = ui_components.ToolButton(value=styles_materialize_symbol, elem_id=f"{tabname}_style_apply_dialog", tooltip="Apply all selected styles from the style selection dropdown in main UI to the prompt.")
self.materialize = ui_components.ToolButton(value=styles_materialize_symbol, elem_id=f"{tabname}_style_apply_dialog", tooltip="Apply all selected styles from the style selection dropdown in main UI to the prompt. Strips comments, if enabled.")
self.copy = ui_components.ToolButton(value=styles_copy_symbol, elem_id=f"{tabname}_style_copy", tooltip="Copy main UI prompt to style.")
with gr.Row():