1 Star 0 Fork 0

襄垣/sd-dynamic-prompts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
jinja_help.html 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
<div class="dynamic-prompting">
Jinja2 templates is an experimental feature for advanced template generation. It is not recommended for general use unless you are comfortable with writing scripts.<br><br>
<h3>Literals</h3>
<pre><code class="codeblock">
I love red roses
</code></pre>
<h3>Random choices</h3>
<pre><code class="codeblock">
I love {{ choice('red', 'blue', 'green') }} roses
</code></pre>
This will randomly choose one of the three colors.<br><br>
<h3>Iterations</h3>
<pre>
<code class="codeblock">
{% for colour in ['red', 'blue', 'green'] %}
{% prompt %}I love {{ colour }} roses{% endprompt %}
{% endfor %}
</code>
</pre>
This will produce three prompts, one for each color. The prompt tag is used to mark the text that will be used as the prompt. If no prompt tag is present then only one prompt is assumed<br><br>
<h3>Wildcards</h3>
<pre>
<code class="codeblock">
{% for colour in wildcard("__colours__") %}
{% prompt %}I love {{ colour }} roses{% endprompt %}
{% endfor %}
</code>
</pre>
This will produce one prompt for each colour in the wildcard.txt file. <br><br>
<h3>Conditionals</h3>
<pre>
<code class="codeblock">
{% for colour in ["red", "blue", "green"] %}
{% if colour == "red"}
{% prompt %}I love {{ colour }} roses{% endprompt %}
{% else %}
{% prompt %}I hate {{ colour }} roses{% endprompt %}
{% endif %}
{% endfor %}
</code>
</pre>
This will produce the following prompts:
<ul>
<li>I love red roses</li>
<li>I hate blue roses</li>
<li>I hate green roses</li>
</ul><br>
Jinja2 templates are based on the Jinja2 template engine. For more information see the <a href="https://jinja.palletsprojects.com/en/3.1.x/templates/">Jinja2 documentation.</a>.<br>
If you are using these templates, please let me know if they are useful.
</div>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/SoftMeng/sd-dynamic-prompts.git
git@gitee.com:SoftMeng/sd-dynamic-prompts.git
SoftMeng
sd-dynamic-prompts
sd-dynamic-prompts
main

搜索帮助