A port of the SD Dynamic Prompts Auto1111 extension to ComfyUI. Includes the most of the original functionality, including:
Templating language for prompts
Variant syntax
A {red|green|blue} ballWeights - e.g.
{0.5::summer|0.1::autumn|0.3::winter|0.1::spring}Select multiple values
My favourite ice-cream flavours are {2$$chocolate|vanilla|strawberry}will produce My favourite ice-cream flavours are chocolate,strawberryCustom separators
My favourite ice-cream flavours are {2$$ and $$chocolate|vanilla|strawberry}will produce My favourite ice-cream flavours are chocolate and strawberryRanges
My favourite ice-cream flavours are {1-2$$chocolate|vanilla|strawberry}
Wildcards
Nested directory hierarchies e.g
__color/warm__Globbing for matching multiple files, e.g .
__color*__txt/yaml/json file formats
Combinatorial mode - will produce all possible variations of your prompt.
I'm Feeling Lucky (downloads prompts from lexica.art)
Magic Prompt - spices up your prompt with modifiers
Jinja2 templates for more advanced prompting requirements
Variable assignment -
${season=!__season__} In ${season}, I wear ${season} shirts and ${season} trousersParameterized templates for re-usable templates, similar to calling a function
Installation
The recommended way to install this extension is by using the ComfyUI Manager.
Get the latest version on Github: https://github.com/adieyal/comfyui-dynamicprompts/
Description
FAQ
Comments (9)
You absolute legend, thanks for this.
Just grabbed this and it's great, thank you...quick question, to get wildcards working do I need to create a new folder called 'wildcards' inside the 'comfyui-dynamicprompts' folder I now have in 'custom_nodes' ???
you need to create a wildcards folder either in the comfui root directory, or inside the comfui-dynamicprompts folder. One user opened an issue saying that he had to put the directory in the same folder as sampler.py (https://github.com/adieyal/comfyui-dynamicprompts/issues/1) - If you have any trouble, try that as a workaround until there is a fix
Edit: I've solved two problems, putting it here in case others encounter them:
1. Failed to import at launch (can't find "dynamicprompts"): Check your ../users/<username>/appdata/local/programs/python/python<version>/lib folder. Look for a folder called dynamicprompts. Move that folder to ../ComfyUI/... wherever it is Python is installed on the drive you're using, and drop it into the lib folder. Basically, you want it to be in the Python folder ComfyUI is looking in, not in the one in your AppData folder. (Unless if course it's looking there, in which case you shouldn't experience this issue in the first place.)
2. Failed to utilize wildcards ("no values found"): Go to../ComfyUI/custom_nodes/comfyui-dynamicprompts/nodes and open sampler.py in your text editor of choice, preferable one meant for coding to make it easier to see what's going on.
Find def find_wildcards_folder(self): which should be on line 35 as of time of writing.
Under this you'll see wildcards_folder = Path ("wildcards").
Replace "wildcards" with "<file path to your wildcards folder>". For example, it might read...
wildcards_folder = Path("D://My Folder/ComfyUI_windows_portable/ComfyUI/wildcards")
Also make sure that your wildcard collections are in this folder, and not within subfolders inside said folder.
python 3.1 - that's awful - even 3.4 is very old. I'm not sure that the dynamic prompts library will even work on such an old installation. In any case, https://github.com/adieyal/dynamicprompts is the library that sd-dynamic-prompts (the auto1111 extension) uses. This comfui extension also uses it, that way you should be able to use your old auto1111 prompts in comfy. If you can't use pip, you can probably just download a release, e.g. https://github.com/adieyal/dynamicprompts/releases/tag/v0.29.0 and then run setup.py in your virtual environment. If at all possible, you really should upgrade your python. Perhaps try pyenv?
I actually do have a standalone pip on here for some reason... I think I got it while playing around with AI language models...? I wonder if I could somehow do it with that. Anyway, I'll try the setup.py method and maybe look into pyenv while I'm at it. Thanks!
@soapsudtycoon Okay! Good news is, setup.py seems to have worked. Bad news is, Comfy's returning this:
"ModuleNotFoundError: No module named 'dynamicprompts'"
Is there a specific directory that Dynamic Prompts has to be in when I run the setup, perhaps...? My first and best guess is that whatever it had to install, it installed to the wrong place.
@Anistasiata It might be that the python you used to install dynamicprompts is not the same one that you are using to run comfy. Find the full path to that python interpreter and use it to run setup.py
Very cool! Thank you. Minor issue: When using wildcard files, I've noticed the wildcard trigger/folder is saved in the prompt EXIF data instead of the actual lines that were randomly selected. Is there any way to save the actual randomly selected line in the EXIF Prompt field? It makes it very difficult to replicate a photo if you don't know what the prompt sent when it was passed through the models.
All my output files have __wildcard__Details
Files
Available On (1 platform)
Same model published on other platforms. May have additional downloads or version variants.


