Added prepending. Now the node has prepend text, the actual batch prompt and append text

This commit is contained in:
ReinerBforartists
2026-02-07 10:34:07 +01:00
parent c3b062b3a6
commit d5e018c5c7
2 changed files with 114 additions and 109 deletions
@@ -158,7 +158,7 @@
"secondTabWidth": 65
},
"widgets_values": [
628132452435800,
975873492175846,
"randomize",
4,
1,
@@ -351,49 +351,6 @@
"z-image"
]
},
{
"id": 56,
"type": "SimplePromptBatcher",
"pos": [
405.21551002213346,
221.44309846775698
],
"size": [
364.4321427873508,
283.66376369960267
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "prompt",
"shape": 6,
"type": "STRING",
"links": [
56,
57
]
}
],
"properties": {
"cnr_id": "comfyui-simple-prompt-batcher",
"ver": "1.0.0",
"Node name for S&R": "SimplePromptBatcher",
"ue_properties": {
"widget_ue_connectable": {},
"input_ue_unconnectable": {},
"version": "7.5.2"
}
},
"widgets_values": [
"A 42-year-old woman with greasy shoulder-length black hair, wearing a frayed lavender robe tied crookedly, stands barefoot in a dim kitchen, staring into an open refrigerator glowing faintly blue. Inside, dozens of identical eggs float in midair, each containing a tiny screaming face. The only light comes from the fridge’s dying bulb, casting long shadows that twitch like living things on the cracked linoleum.\n\nA 6-year-old boy with matted blond curls and a too-large flannel shirt sits cross-legged on a bathroom floor, pressing his forehead against the mirror as his reflection blinks without him. Water drips from the faucet in slow, heavy drops—each splash echoes like a heartbeat. The tiles are covered in peeling stickers of smiling animals, their eyes scratched out.\n\nA man in his late 50s with a shaved head and a stained white lab coat stands motionless beneath a flickering fluorescent tube in an endless corridor lined with identical doors. In his hand: a single key that doesn’t belong to any lock. The air smells of burnt sugar and wet wool. Every door handle is rusted shut, except one—slightly ajar, whispering.\n\n\n\n\n\n\n",
"surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 57,
"type": "CLIPTextEncode",
@@ -490,55 +447,6 @@
},
"widgets_values": []
},
{
"id": 58,
"type": "ShowText|pysssss",
"pos": [
423.00661112698293,
746.4698956378583
],
"size": [
367.4023466274207,
518.2557719909985
],
"flags": {
"collapsed": true
},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "text",
"type": "STRING",
"link": 57
}
],
"outputs": [
{
"name": "STRING",
"shape": 6,
"type": "STRING",
"links": null
}
],
"title": "Show Text - Debugging 🐍",
"properties": {
"cnr_id": "comfyui-custom-scripts",
"ver": "1.2.5",
"Node name for S&R": "ShowText|pysssss",
"ue_properties": {
"version": "7.0.1",
"widget_ue_connectable": {}
}
},
"widgets_values": [
"A 42-year-old woman with greasy shoulder-length black hair, wearing a frayed lavender robe tied crookedly, stands barefoot in a dim kitchen, staring into an open refrigerator glowing faintly blue. Inside, dozens of identical eggs float in midair, each containing a tiny screaming face. The only light comes from the fridge’s dying bulb, casting long shadows that twitch like living things on the cracked linoleum., surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed",
"A 6-year-old boy with matted blond curls and a too-large flannel shirt sits cross-legged on a bathroom floor, pressing his forehead against the mirror as his reflection blinks without him. Water drips from the faucet in slow, heavy drops—each splash echoes like a heartbeat. The tiles are covered in peeling stickers of smiling animals, their eyes scratched out., surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed",
"A man in his late 50s with a shaved head and a stained white lab coat stands motionless beneath a flickering fluorescent tube in an endless corridor lined with identical doors. In his hand: a single key that doesn’t belong to any lock. The air smells of burnt sugar and wet wool. Every door handle is rusted shut, except one—slightly ajar, whispering., surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed"
],
"color": "#432",
"bgcolor": "#653"
},
{
"id": 35,
"type": "MarkdownNote",
@@ -553,7 +461,7 @@
"flags": {
"collapsed": false
},
"order": 4,
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [],
@@ -577,7 +485,7 @@
110
],
"flags": {},
"order": 5,
"order": 4,
"mode": 0,
"inputs": [],
"outputs": [
@@ -607,6 +515,99 @@
576,
1
]
},
{
"id": 56,
"type": "SimplePromptBatcher",
"pos": [
405.21551002213346,
221.44309846775698
],
"size": [
364.4321427873508,
283.66376369960267
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "prompt",
"shape": 6,
"type": "STRING",
"links": [
56,
57
]
}
],
"properties": {
"cnr_id": "comfyui-simple-prompt-batcher",
"ver": "1.0.0",
"Node name for S&R": "SimplePromptBatcher",
"ue_properties": {
"widget_ue_connectable": {},
"input_ue_unconnectable": {},
"version": "7.5.2"
}
},
"widgets_values": [
"a room with neon light, a teddybear",
"A 42-year-old woman with greasy shoulder-length black hair, wearing a frayed lavender robe tied crookedly, stands barefoot in a dim kitchen, staring into an open refrigerator glowing faintly blue. Inside, dozens of identical eggs float in midair, each containing a tiny screaming face. The only light comes from the fridge’s dying bulb, casting long shadows that twitch like living things on the cracked linoleum.\n\nA 6-year-old boy with matted blond curls and a too-large flannel shirt sits cross-legged on a bathroom floor, pressing his forehead against the mirror as his reflection blinks without him. Water drips from the faucet in slow, heavy drops—each splash echoes like a heartbeat. The tiles are covered in peeling stickers of smiling animals, their eyes scratched out.\n\nA man in his late 50s with a shaved head and a stained white lab coat stands motionless beneath a flickering fluorescent tube in an endless corridor lined with identical doors. In his hand: a single key that doesn’t belong to any lock. The air smells of burnt sugar and wet wool. Every door handle is rusted shut, except one—slightly ajar, whispering.\n",
"surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 58,
"type": "ShowText|pysssss",
"pos": [
423.00661112698293,
746.4698956378583
],
"size": [
345.5792930551006,
518.2557719909985
],
"flags": {
"collapsed": true
},
"order": 8,
"mode": 4,
"inputs": [
{
"name": "text",
"type": "STRING",
"link": 57
}
],
"outputs": [
{
"name": "STRING",
"shape": 6,
"type": "STRING",
"links": null
}
],
"title": "Show Text - Debugging 🐍",
"properties": {
"cnr_id": "comfyui-custom-scripts",
"ver": "1.2.5",
"Node name for S&R": "ShowText|pysssss",
"ue_properties": {
"version": "7.0.1",
"widget_ue_connectable": {}
}
},
"widgets_values": [
"a room with neon light, a teddybear, A 42-year-old woman with greasy shoulder-length black hair, wearing a frayed lavender robe tied crookedly, stands barefoot in a dim kitchen, staring into an open refrigerator glowing faintly blue. Inside, dozens of identical eggs float in midair, each containing a tiny screaming face. The only light comes from the fridge’s dying bulb, casting long shadows that twitch like living things on the cracked linoleum., surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed",
"a room with neon light, a teddybear, A 6-year-old boy with matted blond curls and a too-large flannel shirt sits cross-legged on a bathroom floor, pressing his forehead against the mirror as his reflection blinks without him. Water drips from the faucet in slow, heavy drops—each splash echoes like a heartbeat. The tiles are covered in peeling stickers of smiling animals, their eyes scratched out., surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed",
"a room with neon light, a teddybear, A man in his late 50s with a shaved head and a stained white lab coat stands motionless beneath a flickering fluorescent tube in an endless corridor lined with identical doors. In his hand: a single key that doesn’t belong to any lock. The air smells of burnt sugar and wet wool. Every door handle is rusted shut, except one—slightly ajar, whispering., surrealistic, worn look, strong colors, dramatic lighting, unreal engine, rendering, cinematic composition, highly detailed"
],
"color": "#432",
"bgcolor": "#653"
}
],
"links": [
@@ -753,8 +754,8 @@
"ds": {
"scale": 0.9531171560791476,
"offset": [
140.5027772954123,
-35.67271407407783
414.01505676533793,
-81.72652487282919
]
},
"frontendVersion": "1.37.11",
+16 -12
View File
@@ -1,6 +1,6 @@
"""
ComfyUI Simple Prompt Batcher with Global Style (Robust Version)
Takes multiple prompts (one per line) and appends a global style to all prompts for batch processing
Takes multiple prompts (one per line) and prepends and appends a global string to all prompts for batch processing
Includes extra safeguards to prevent duplicate prompts or ComfyUI misinterpretation
"""
@@ -15,17 +15,23 @@ class SimplePromptBatcher:
def INPUT_TYPES(cls):
return {
"required": {
"prepend": ("STRING", {
"default": "",
"multiline": True,
"placeholder": "Text to prepend to all prompts",
"tooltip": "Text prepended to every prompt."
}),
"prompts": ("STRING", {
"default": "",
"multiline": True,
"placeholder": "Prompts (one per line). Enter one prompt per line. No empty lines between prompts.",
"tooltip": "Each line is treated as a separate prompt for batch processing."
}),
"style": ("STRING", {
"append": ("STRING", {
"default": "",
"multiline": True,
"placeholder": "Global Style. Optional: style string appended to all prompts.",
"tooltip": "Define a style prompt that gets appended to every prompt in the list."
"placeholder": "Text to append to all prompts",
"tooltip": "Text appended to every prompt."
}),
}
}
@@ -36,10 +42,10 @@ class SimplePromptBatcher:
CATEGORY = "utils/text"
OUTPUT_IS_LIST = (True,) # This makes it output as a batch
def batch_prompts(self, prompts, style=""):
def batch_prompts(self, prepend="", prompts="", append=""):
"""
Split prompts by newline and return as batch
Each line becomes a separate inference
Format: [prepend] + prompt + [append]
"""
# Split by newline and remove empty lines / trim spaces
@@ -49,12 +55,10 @@ class SimplePromptBatcher:
print("[Prompt Batcher] ⚠️ No prompts provided, returning empty prompt")
return ([""],)
# Append style safely if provided, avoiding duplicates
if style:
prompt_list = [
f"{p}, {style}" if style not in p else p
for p in prompt_list
]
prompt_list = [
f"{prepend}{', ' if prepend else ''}{p}{', ' if append else ''}{append}"
for p in prompt_list
]
# Debug: print each prompt for verification
print(f"[Prompt Batcher] 📋 Batching {len(prompt_list)} prompts:")