图像分区 · 替换编辑 Prompt 合约
One instruction in, three ready-to-use prompts out — tuned for the model you actually chose
- klein_prompt
- gpt_text_only_prompt
- gpt_reference_prompt
Here's a friction point every multi-model workflow has: the edit instruction you want is one sentence - "replace the coffee cup with a bowl of rice" - but the prompt you actually feed the model depends on which model you picked, because Kontext, Klein, Qwen-Edit and friends want subtly different framing. RegionEditReplacementPromptContract solves it by taking your single replacement_instruction and emitting three ready-to-use prompts, one per route, so you don't maintain three versions of the same sentence by hand.
The three outputs are the payload: klein_prompt, gpt_text_only_prompt, and gpt_reference_prompt. The names map to the pack's two engines. klein_prompt is framed for FLUX.2 Klein, the local instruction-edit model this pack is built around - and since Klein takes the whole crop as context, the prompt leans on explicit preservation ("keep everything else unchanged"). The two GPT variants are the text-only and reference-guided framings for an LLM-based edit route; the reference version carries the constraint that the reference image is a visual guide only - "do not copy Image 2's background, composition, people, lighting, shadows, or surface," from the source. That distinction - reference for the object, not for the scene - is exactly the instruction that stops a replacement from dragging a whole new environment along with it.
The single input is replacement_instruction (multiline, default "把选中的物品替换成目标物,保持其他内容不变。" - "replace the selected item with the target object, keep everything else unchanged"). It refuses empty input with a clear error, because a blank replacement instruction is the one case where garbage-in won't even produce garbage-out, it'll produce nothing.
Where it sits: in the object-replacement workflow, this is the prompt-contract stage - after SAM3 has found the object and before the chosen engine actually edits. Pair the klein_prompt output with RegionEditPreservationPromptBuilder's preservation suffix and you've got a well-framed Klein instruction. Pair the GPT outputs with an LLM-in-ComfyUI route (the pack supports that alternative path) and you've got the same intent in that model's preferred framing.
You'll notice this node shares the pack's bilingual DNA - the default instruction is Chinese, because the author's users write instructions in Chinese and the pack translates where needed. If you're an English speaker, just type English; nothing here assumes you're the target audience.
Install: ComfyUI Manager → Region Edit Toolkit (native-region-tile-planner-merge), or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into custom_nodes, pip-install requirements.txt into ComfyUI's real Python, restart. Pure text assembly - no models, no network.
The one thing to internalize: these prompts are contracts, not magic. They encode the author's opinion of what each model needs to hear, and that opinion is solid for Klein (the pack's primary engine) but worth a skeptical eye if you swap in a different model. Feed the outputs to a text preview node once before you trust them on a full run - the toolkit is too new to have community tuning lore, and a thirty-second read beats an hour of debugging a prompt that framed things oddly for your model.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| replacement_instruction | STRING | 把选中的物品替换成目标物,保持其他内容不变。 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| klein_prompt | STRING | — |
| gpt_text_only_prompt | STRING | — |
| gpt_reference_prompt | STRING | — |