mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-20 03:13:30 +00:00
Merge branch 'comment-syntax' of https://github.com/space-nuko/ComfyUI
This commit is contained in:
commit
8b82f79cb2
@ -162,6 +162,8 @@ You can use () to change emphasis of a word or phrase like: (good code:1.2) or (
|
|||||||
|
|
||||||
You can use {day|night}, for wildcard/dynamic prompts. With this syntax "{wild|card|test}" will be randomly replaced by either "wild", "card" or "test" by the frontend every time you queue the prompt. To use {} characters in your actual prompt escape them like: \\{ or \\}.
|
You can use {day|night}, for wildcard/dynamic prompts. With this syntax "{wild|card|test}" will be randomly replaced by either "wild", "card" or "test" by the frontend every time you queue the prompt. To use {} characters in your actual prompt escape them like: \\{ or \\}.
|
||||||
|
|
||||||
|
Dynamic prompts also support C-style comments, like `// comment` or `/* comment */`.
|
||||||
|
|
||||||
To use a textual inversion concepts/embeddings in a text prompt put them in the models/embeddings directory and use them in the CLIPTextEncode node like this (you can omit the .pt extension):
|
To use a textual inversion concepts/embeddings in a text prompt put them in the models/embeddings directory and use them in the CLIPTextEncode node like this (you can omit the .pt extension):
|
||||||
|
|
||||||
```embedding:embedding_filename.pt```
|
```embedding:embedding_filename.pt```
|
||||||
|
@ -3,6 +3,13 @@ import { app } from "../../scripts/app.js";
|
|||||||
// Allows for simple dynamic prompt replacement
|
// Allows for simple dynamic prompt replacement
|
||||||
// Inputs in the format {a|b} will have a random value of a or b chosen when the prompt is queued.
|
// Inputs in the format {a|b} will have a random value of a or b chosen when the prompt is queued.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Strips C-style line and block comments from a string
|
||||||
|
*/
|
||||||
|
function stripComments(str) {
|
||||||
|
return str.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,'');
|
||||||
|
}
|
||||||
|
|
||||||
app.registerExtension({
|
app.registerExtension({
|
||||||
name: "Comfy.DynamicPrompts",
|
name: "Comfy.DynamicPrompts",
|
||||||
nodeCreated(node) {
|
nodeCreated(node) {
|
||||||
@ -15,7 +22,7 @@ app.registerExtension({
|
|||||||
for (const widget of widgets) {
|
for (const widget of widgets) {
|
||||||
// Override the serialization of the value to resolve dynamic prompts for all widgets supporting it in this node
|
// Override the serialization of the value to resolve dynamic prompts for all widgets supporting it in this node
|
||||||
widget.serializeValue = (workflowNode, widgetIndex) => {
|
widget.serializeValue = (workflowNode, widgetIndex) => {
|
||||||
let prompt = widget.value;
|
let prompt = stripComments(widget.value);
|
||||||
while (prompt.replace("\\{", "").includes("{") && prompt.replace("\\}", "").includes("}")) {
|
while (prompt.replace("\\{", "").includes("{") && prompt.replace("\\}", "").includes("}")) {
|
||||||
const startIndex = prompt.replace("\\{", "00").indexOf("{");
|
const startIndex = prompt.replace("\\{", "00").indexOf("{");
|
||||||
const endIndex = prompt.replace("\\}", "00").indexOf("}");
|
const endIndex = prompt.replace("\\}", "00").indexOf("}");
|
||||||
|
Loading…
Reference in New Issue
Block a user