adieyal / comfyui-dynamicprompts

ComfyUI custom nodes for Dynamic Prompts
MIT License
187 stars 20 forks source link

Showstopping bug in Jinja2 Templates #21

Open ansorre opened 10 months ago

ansorre commented 10 months 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 9 months ago

Took example from documentation and wildcards seems not to work

GilElendil commented 3 days 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