adieyal / comfyui-dynamicprompts

ComfyUI custom nodes for Dynamic Prompts
MIT License
252 stars 28 forks source link

Showstopping bug in Jinja2 Templates #21

Open ansorre opened 1 year ago

ansorre commented 1 year ago

Privided that I have colors.txt correctly filled with colors and saved in the right directory (wildcards under ComfyUI), if I add a Random Prompts node with the text "a colors cat" everything works well!

But if I add a Jinja2 Templates node with this text:

{% set color1=wildcard("colors")|random %} a {{color1}} cat

I get the warning (which in reality is an error): WARNING:dynamicprompts.samplers.utils:No values found for wildcard colors And the prompt remains: a colors cat

Not even a workaround passing this string to a Random Prompts is possibile because "Convert text to input" is missing in Random Prompts node. Someone has an idea about how to solve these problems?

linnkoln commented 1 year ago

Took example from documentation and wildcards seems not to work

GilElendil commented 5 months ago

I found the issue and managed to put an (ugly) patch on it, but I'm not so good at coding to solve it for real and send a commit.

The problem is on jinjagenerator.py line 40

 self._wildcard_manager = wildcard_manager or WildcardManager()

where WildcardManager is called without passing a path. If you change it to:

self._wildcard_manager = wildcard_manager or WildcardManager('insert-your-wildcard-path-here')

It works.

Well, I know real programmers would tear their eyes out if presented with such code ... but thats as much as I'm able to figure out. :-) Hope someone fixes it for real