adieyal / sd-dynamic-prompts

A custom script for AUTOMATIC1111/stable-diffusion-webui to implement a tiny template language for random prompt generation
MIT License
2.02k stars 261 forks source link

[bug/feature request?] Error when trying to use variables in a range of options #625

Open gustavoGazevedo opened 1 year ago

gustavoGazevedo commented 1 year ago

I'm not entirely sure this is not the expected behavior, in which case this would be a feature request. When trying to use a variable to set a range, I get an error.

prompt: __test/test2(trigger=1)__ wildcard test2: {${trigger:1-3}$$__test/test__}

log error:

*** Error running process: [Path Removed]\stable-diffusion-webui\extensions\sd-dynamic-prompts\scripts\dynamic_prompting.py
Traceback (most recent call last):
File "[Path Removed]\stable-diffusion-webui\modules\scripts.py", line 619, in process
script.process(p, *script_args)
File "[Path Removed]\stable-diffusion-webui\extensions\sd-dynamic-prompts\sd_dynamic_prompts\dynamic_prompting.py", line 485, in process
all_prompts, all_negative_prompts = generate_prompts(
File "[Path Removed]\stable-diffusion-webui\extensions\sd-dynamic-prompts\sd_dynamic_prompts\helpers.py", line 93, in generate_prompts
all_prompts = prompt_generator.generate(prompt, num_prompts, seeds=seeds) or [""]
File "[Path Removed]\venv\lib\site-packages\dynamicprompts\generators\randomprompt.py", line 71, in generate
prompts.append(next(iter(gen)))
File "[Path Removed]\venv\lib\site-packages\dynamicprompts\samplers\random.py", line 118, in _get_wildcard
yield from context.sample_prompts(value, 1)
File "[Path Removed]\venv\lib\site-packages\dynamicprompts\sampling_context.py", line 119, in sample_prompts
command = parse(prompt, parser_config=self.parser_config)
File "[Path Removed]\venv\lib\site-packages\dynamicprompts\parser\parse.py", line 458, in parse
tokens = get_cached_parser(parser_config).parse_string(
File "[Path Removed]\venv\lib\site-packages\pyparsing\core.py", line 1141, in parse_string
raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected end of text, found '{' (at char 0), (line:1, col:1)

The behavior I expected was for the variables to be the first to be parsed, and then the prompt {1$$__test/test__} would parse as normal