Dynamic Prompts is a Python library designed for creating flexible and expressive prompt templates for text-to-image generators like Stable Diffusion, MidJourney, or Dall-e 2. It enables users to generate a multitude of unique prompts from a single template using features such as variants, wildcards, and combinatorial generation. The library is actively maintained, with its current version being 0.31.0, and receives regular updates.
pip install dynamicpromptsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `RandomPromptGenerator` and `WildcardManager` to create dynamic prompts. It uses both inline variants (`{option1|option2}`) and a simple wildcard file (`__colours__`) to show how diverse prompts can be generated from a single template. The `WILDCARD_DIR` is created locally, and a sample wildcard file is generated for immediate execution.
Be aware that the actual number of generated prompts might be less than `num_prompts` if the template's possible variations are exhausted. For precise control over combinatorial generation, consider using `CombinatorialPromptGenerator` and inspecting its `get_template_variants()` method or explicitly setting `max_prompts`.
Ensure you have sufficient disk space and a stable internet connection for the initial download. If encountering CUDA errors, verify your system meets the VRAM requirements or consider running on a CPU if performance is not critical.
Carefully review template syntax. The library expects specific delimiters for variants (`{item1|item2}`) and wildcards (`__wildcard__`). Test your templates thoroughly with smaller `num_prompts` counts to catch issues early. Refer to the official syntax guide for details.Install `dynamicprompts` with its optional dependencies using `pip install "dynamicprompts[magicprompt, attentiongrabber]"` or specifically for the feature you need (e.g., `pip install "dynamicprompts[magicprompt]"`).
Inspect your prompt templates for any syntax errors, such as mismatched braces (`{}`), incorrect wildcard delimiters (`__wildcard__`), or invalid variant syntax (`{opt1|opt2}`). Test with a very simple template first to isolate the issue. Check GitHub issues for similar parsing problems.