ComfyUI Node

VSmartPrompt

VSmartPrompt - Dynamic Prompts with a rich-text editor, variables and post-run highlighting. Place a new instance of this node to get the full instructions. INPUTS: line_suffix: Appends this string to the end of every line. Useful to automate suffixing of tags and descriptive text with either commas or single dots. single_line_output: This must be True for multi-line combinations to work. remove_whitespaces: Trims every line and converts multiple spaces to single space, ex: ' ' -> ' '. Also removes empty lines. remove_empty_tags: 'tags' here is anything between dots or commas. Fixes cases like this: 'cat,, , dog' -> 'cat, dog'. load_loras_from_prompt: Legacy compatibility toggle kept only to preserve widget ordering in older workflows. remove_loras_pattern: Legacy compatibility toggle that strips LoRA tags from the output prompt text. wildcard_directory: The directory where TXT wildcard files are stored.

By vangel76·Created 19 days ago·Updated 3 days ago· 0
VSmartPrompt
  • vars_in
  • prompt
  • original_prompt
  • variables
available_loras_stem
seed0
line_suffix
single_line_outputtrue
remove_whitespacestrue
remove_empty_tagstrue
load_loras_from_prompttrue
remove_loras_patterntrue
wildcard_directory/tmp/ComfyUI/custom_nodes/comfyui-ValiTools/wildcards
prompt### Instructions and Tips ## SYNTAX: ## COMBINATIONS # They use '{' and '}' delimiters with '|' as separator. # Distribution is even by default but you can specify custom choice distribution using 'N::' prefix where N is a number from 0 to 1. # Examples: A {red|blue} car. # 50% chance for both red and blue A {green|} bird. # 50% chance for 'green' and 50% for empty string {0.1::green|0.2::yellow|{pink|red}} background. # 10% chance for green, 20% for yellow and 70% for {pink|red} {child|{jumping up|running} {cat|{large|small}dog}|boring human}. # nested posible with levels colored differently ## WILDCARDS # These pull a random non-empty line from a TXT file directly stored in 'wildcard_directory'. # They use double underscore delimiters and its content should be the filename without extension. # Single '#' comments still go until the end of the line, but '#comment#' can now be used inline too. # When 'wildcard_directory\filename.txt' does not exist -> the __filename__ string will remain in the prompt. # Wildcards are highlighted as YELLOW when they point to a .txt file that exists - otherwise, RED. # This highlight feature only supports up to 4 nested subfolders - wildcards pointing to deeper files will still work but show up as red. # You can add comments and combinations within wildcards but try to not create infinite loops when doing so - the node has safety against that though. __ThisIsAWildCard__ # pulls from 'wildcard_directory\ThisIsAWildCard.txt' but I don't have that file so this string will appear in the final prompt __Folder1\Folder2\ThisIsAWildCard__ # sub-directory support - will pull from 'wildcard_directory\Folder1\Folder2\ThisIsAWildCard.txt' ## You can nest combinations and wildcards at will (ex: combination within wildcard within combination ...) ## VARIABLES # Append '==<name>' right after a combination or wildcard to remember its resolved value. # The assignment still outputs its value where it stands - it just also saves it for reuse. # Reuse the value anywhere AFTER the assignment - even inside later combinations or wildcards - by writing <name>. # Names may contain letters, digits and underscores and are case-insensitive. Reassigning a name overwrites its value. # A <name> that is never assigned anywhere stays as-is in the output (and shows up RED in the editor). # Plain text works too: 'fore-head==<part>' stores the single word (no spaces) right before '=='. # That also works inside combination branches - only the SELECTED branch's assignment happens: her {face==<part>|fore-head==<part>|head==<part>} # For a fixed MULTI-WORD text use a single-choice combination: {crime scene}==<loc> # SILENT assignment: '==!<name>' stores the value but outputs NOTHING where it stands - only the <name> references output it. # NODE INPUTS: text connected to the in1..in4 input sockets is available here as <in1>..<in4> - chain VSmartPrompt nodes by wiring one's output into another's socket. # VARIABLE HAND-OVER: wire a node's 'variables' output into the next node's 'vars_in' input and every <name> it assigned works there too (and travels on down the chain). # TIP: typing '<' opens a dropdown with all assigned variables - type to filter, UP/DOWN + ENTER/TAB or click to insert, ESC to close. {blonde|ginger}==<haircolor> hair # picks one AND remembers the pick her {light <haircolor>|dark <haircolor>} eyebrows match her <haircolor> hair __names__==<girlname> enters. Say hi to <girlname>! {sunny|rainy|foggy}==!<weather> # rolls + remembers, outputs nothing here the <weather> morning turns into a <weather> afternoon ## SWITCHER (conditional blocks) # Gate a combination or wildcard on a variable's value: glue '<name>==value::' DIRECTLY in front of it. # Value matches (case-insensitive) -> it resolves normally. No match -> the whole thing outputs nothing. # '<name>!=value::' is the NOT form: fires for every value EXCEPT the given one. # Assign the tag BEFORE the switch. Silent branch tags are perfect for this: she is {cutting the wedding cake cake==!<act>|holding a champagne glas glass==!<act>|dancing dance==!<act>}. <act>==cake::{she serves the cake|she cuts another slice} <act>!=cake::{she is not near the cake} # fires for glass AND dance <act>==cake::__cake_actions__ # wildcards can be gated too ## Word weightning # This is already natively supported by ComfyUI - in case you didn't know, it reinforces the importance of the encased words. (car or something:1.2) # Just showcasing that these are also highlighted ## Hotkeys/Shortcuts/Misc: # - CTRL + Left Mouse Click on a Yellow wildcard -> opens the file with your default text editor (Notepad++ recommended) # - CTRL + Left Mouse Click on a Red wildcard -> creates and opens the file with your default text editor (Notepad++ recommended) # - Adjust Font Size with CTRL + Mouse Wheel Up/Down # - CTRL + UP/DOWN (on selected text) mimics ComfyUI's fast text weighting ## TIPS: # - This node is (accidentally) fully compatible with subgraphs. This means you can actually add the 'prompt area' as a widget to the subgraph's widgets! # To do so: place the node inside a subgraph then outside the subgraph -> right click on it -> Edit subgraph widgets -> Search 'vsmart' and turn the visibility ON for 'richprompt_widget_-1'
in1
in2
in3
in4
CategoryValiTools

Inputs (15)

NameTypeDefaultDescription
available_loras_stemSTRINGCompatibility placeholder for older workflows. This field is kept only to preserve widget ordering.
seedINT00–18446744073709550000Same seed + same prompt + same connected in1-in4 texts always returns the same output prompt. Changed input text re-rolls the picks even with a fixed seed.
line_suffixSTRINGAppends this string to the end of every line. Useful to automate suffixing of tags and descriptive text with either commas or single dots.
single_line_outputBOOLEANtrueThis must be True for multi-line combinations to work.
remove_whitespacesBOOLEANtrueTrims every line and converts multiple spaces to single space, ex: ' ' -> ' '. Also removes empty lines.
remove_empty_tagsBOOLEANtrue'tags' here is anything between dots or commas. Fixes cases like this: 'cat,, , dog' -> 'cat, dog'.
load_loras_from_promptBOOLEANtrueCompatibility placeholder for older workflows. LoRA loading is no longer handled by this node.
remove_loras_patternBOOLEANtrueCompatibility placeholder for older workflows. When enabled, LoRA tags are stripped from the final prompt text.
wildcard_directorySTRING/tmp/ComfyUI/custom_nodes/comfyui-ValiTools/wildcardsThe directory where TXT wildcard files are stored.
promptoptSTRING### Instructions and Tips ## SYNTAX: ## COMBINATIONS # They use '{' and '}' delimiters with '|' as separator. # Distribution is even by default but you can specify custom choice distribution using 'N::' prefix where N is a number from 0 to 1. # Examples: A {red|blue} car. # 50% chance for both red and blue A {green|} bird. # 50% chance for 'green' and 50% for empty string {0.1::green|0.2::yellow|{pink|red}} background. # 10% chance for green, 20% for yellow and 70% for {pink|red} {child|{jumping up|running} {cat|{large|small}dog}|boring human}. # nested posible with levels colored differently ## WILDCARDS # These pull a random non-empty line from a TXT file directly stored in 'wildcard_directory'. # They use double underscore delimiters and its content should be the filename without extension. # Single '#' comments still go until the end of the line, but '#comment#' can now be used inline too. # When 'wildcard_directory\filename.txt' does not exist -> the __filename__ string will remain in the prompt. # Wildcards are highlighted as YELLOW when they point to a .txt file that exists - otherwise, RED. # This highlight feature only supports up to 4 nested subfolders - wildcards pointing to deeper files will still work but show up as red. # You can add comments and combinations within wildcards but try to not create infinite loops when doing so - the node has safety against that though. __ThisIsAWildCard__ # pulls from 'wildcard_directory\ThisIsAWildCard.txt' but I don't have that file so this string will appear in the final prompt __Folder1\Folder2\ThisIsAWildCard__ # sub-directory support - will pull from 'wildcard_directory\Folder1\Folder2\ThisIsAWildCard.txt' ## You can nest combinations and wildcards at will (ex: combination within wildcard within combination ...) ## VARIABLES # Append '==<name>' right after a combination or wildcard to remember its resolved value. # The assignment still outputs its value where it stands - it just also saves it for reuse. # Reuse the value anywhere AFTER the assignment - even inside later combinations or wildcards - by writing <name>. # Names may contain letters, digits and underscores and are case-insensitive. Reassigning a name overwrites its value. # A <name> that is never assigned anywhere stays as-is in the output (and shows up RED in the editor). # Plain text works too: 'fore-head==<part>' stores the single word (no spaces) right before '=='. # That also works inside combination branches - only the SELECTED branch's assignment happens: her {face==<part>|fore-head==<part>|head==<part>} # For a fixed MULTI-WORD text use a single-choice combination: {crime scene}==<loc> # SILENT assignment: '==!<name>' stores the value but outputs NOTHING where it stands - only the <name> references output it. # NODE INPUTS: text connected to the in1..in4 input sockets is available here as <in1>..<in4> - chain VSmartPrompt nodes by wiring one's output into another's socket. # VARIABLE HAND-OVER: wire a node's 'variables' output into the next node's 'vars_in' input and every <name> it assigned works there too (and travels on down the chain). # TIP: typing '<' opens a dropdown with all assigned variables - type to filter, UP/DOWN + ENTER/TAB or click to insert, ESC to close. {blonde|ginger}==<haircolor> hair # picks one AND remembers the pick her {light <haircolor>|dark <haircolor>} eyebrows match her <haircolor> hair __names__==<girlname> enters. Say hi to <girlname>! {sunny|rainy|foggy}==!<weather> # rolls + remembers, outputs nothing here the <weather> morning turns into a <weather> afternoon ## SWITCHER (conditional blocks) # Gate a combination or wildcard on a variable's value: glue '<name>==value::' DIRECTLY in front of it. # Value matches (case-insensitive) -> it resolves normally. No match -> the whole thing outputs nothing. # '<name>!=value::' is the NOT form: fires for every value EXCEPT the given one. # Assign the tag BEFORE the switch. Silent branch tags are perfect for this: she is {cutting the wedding cake cake==!<act>|holding a champagne glas glass==!<act>|dancing dance==!<act>}. <act>==cake::{she serves the cake|she cuts another slice} <act>!=cake::{she is not near the cake} # fires for glass AND dance <act>==cake::__cake_actions__ # wildcards can be gated too ## Word weightning # This is already natively supported by ComfyUI - in case you didn't know, it reinforces the importance of the encased words. (car or something:1.2) # Just showcasing that these are also highlighted ## Hotkeys/Shortcuts/Misc: # - CTRL + Left Mouse Click on a Yellow wildcard -> opens the file with your default text editor (Notepad++ recommended) # - CTRL + Left Mouse Click on a Red wildcard -> creates and opens the file with your default text editor (Notepad++ recommended) # - Adjust Font Size with CTRL + Mouse Wheel Up/Down # - CTRL + UP/DOWN (on selected text) mimics ComfyUI's fast text weighting ## TIPS: # - This node is (accidentally) fully compatible with subgraphs. This means you can actually add the 'prompt area' as a widget to the subgraph's widgets! # To do so: place the node inside a subgraph then outside the subgraph -> right click on it -> Edit subgraph widgets -> Search 'vsmart' and turn the visibility ON for 'richprompt_widget_-1'
in1optSTRINGExternal text, reference it in the prompt as <in1>. Inserted as-is (not re-resolved). The upstream branch only executes if <in1> appears in the prompt.
in2optSTRINGExternal text, reference it in the prompt as <in2>. Inserted as-is (not re-resolved). The upstream branch only executes if <in2> appears in the prompt.
in3optSTRINGExternal text, reference it in the prompt as <in3>. Inserted as-is (not re-resolved). The upstream branch only executes if <in3> appears in the prompt.
in4optSTRINGExternal text, reference it in the prompt as <in4>. Inserted as-is (not re-resolved). The upstream branch only executes if <in4> appears in the prompt.
vars_inoptVS_VARSVariables from another VSmartPrompt: wire its 'variables' output here and every <name> it assigned is available in this prompt (and is passed on again).

Outputs (3)

NameTypeDescription
promptSTRING
original_promptSTRING
variablesVS_VARS