ComfyUI Extension: comfyui-creativeprompts
A creative alternative to dynamicprompts
Custom Nodes (0)
README
Creative Prompts
Introduction
This is an alternative to dynamic-prompts, which has served as the bread and butter of creative prompt building for years. Sadly, it hasn't been updated in years now. Something needed to be done, because so much more can be done.
This project aims to revisit the dynamic prompting system from the ground up with a fresh perspective. This brings an arsenal of new tools for both dynamic prompts and strings in general, including:
- Wildcard Rewrapping
- Converts words or phrases back into wildcard prompts
- Precaches for quick lookups
- Wildcard Replace
- Systematic replacement for strings
- Shuffle Tags
- Shuffles a string based on a delimiter (typically a comma).
- The advanced version allows for more shaping of this effect, such as falloff, or walking shuffle.
-
Basics
(Feel free to skip this section if you are familiar with dynamic prompts, but be advised, not all features from dynamicprompts are implemented here)
Creative Prompting 101
There are two methods to random a prompt.
Input: __masterpiece__, __scene_forest__, __quality__
Recursive Processing 1: masterpiece, __adj__ forest with {2-3$$ {__and__|,} $$__plants__|__trees__|__grass__}, __lighting__, high-quality, highres
Recursive Processing 2: masterpiece, __wonderful__ forest with willow trees with a patch of grass and __flowers__, __bushfruit__ bushes, __lighting_nature__, high-quality, highres
Result: masterpiece, magnificent forest with willow trees with a patch of grass and daffodils, blueberry bushes, dynamic outdoor lighting with shadows, high-quality, highres
New Features
Lora Tags Survive
Dynamic prompting should no longer get completely derailed simply because of an unfortunate naming convention by a lora. So <lora:coolest__lora__ever__:1.0>
will survive.
Separator Wildcard
Let's say that and.txt contains the following:
and
or
with
Then we use that wildcard as the separator token for a bracket wildcard:
{3-4$$ __and__ $$A|B|C|D|E}
example outputs:
A or E and B
C and D with B or A
B with C and D
Wildcard Rewrap
Does the inverse of Encapsulates keywords with a wildcard file they exist in.
Example Input:
table and color apple
Example Output:
__furniture__ and __color__ __fruit__
The purpose of this node is to allow you to write with natural language, then wrapping it in a dynamic and creative way.
Wildcard Replace
Acts as a standard String Replace function, with a twist. The search string and replace string both accept wildcards.
the quick brown fox jumped over the lazy dog
Quickstart Guide
Bracket Wildcards
Basic usage:
{apple|orange|banana}
Randomly returns one of the selections.
{3$$apple|orange|banana}
Returns 3 of the selections, separated by a comma:
Example: orange, apple, banana
Custom separator:
{3$$ and $$apple|orange|banana}
Returns 3 selections separated by "and"
:
Example: orange and apple and banana
Range of selections:
{3-5$$ and $$apple|orange|banana}
Randomly selects between 3 and 5 items with a custom separator.
Wildcard separator:
{3-5$$ __and__ $$apple|orange|banana}
The separator itself can be a wildcard for more unique phrasing combinations.
Example: orange or apple and banana
Note: Using a bracket wildcard for the separator, e.g.:
{5$$ {and|or} $$A|B|C|D|E|F|G}
will pick a separator once per combination:
Example: B or G or C or F or E
This is by design to allow for separate modes. Shuffling with a file wildcard can produce more variation and allow for.
File Wildcards
Basic usage:
__fruit__
Pulls a random value from /wildcards/fruit.txt
.
File wildcards can also be nested inside brackets or other file wildcards for dynamic combinations.
Chance Weights
A very simple chance weighting system is included.
Here's a chance.txt
wildcard example:
#
%80% common
%10% uncommon
rare # default is 1
%0.1% ultrarare
Additional Notes
- Bracket and file wildcards support recursive nesting.
- You can specify ranges, custom separators, and even wildcard separators.
- Comments in wildcard files are supported using
#
at the start of a line. - Optional weights can be added to lines using
%number%
anywhere in the line to influence selection probability. - Escaped percent signs (
\%
) are preserved in the output.
Disclaimer
I do not intend to recreate Dynamic Prompts one-to-one. I'll be utilizing the foundational concept and syntax as a starting point.
Python is not my go-to language, so take this for what you will, or contribute if you feel inclined.
I also have no plans to adapt this to A1111 / Forge.