Nodes/ComfyUI-Magic-Assistant/✨ 多功能AI提示词替换 Magic Multi-Function AI Prompt Replace
ComfyUI Node

✨ 多功能AI提示词替换 Magic Multi-Function AI Prompt Replace

Swap characters, translate, or fix grammar

By shigjfg·Created 9 months ago·Updated 5 days ago· 45
✨ 多功能AI提示词替换 Magic Multi-Function AI Prompt Replace
  • image
  • modified_prompt
◄original_prompt—►
◄replace_tag—►
◄llm_profile▾►
◄rule_name▾►
◄rewrite_backendllm►
◄local_profile▾►
◄original_prompt_in—►

Some prompt edits are mechanical - swap the character, change the background, flip the gender - and doing them by hand means retyping half the prompt and hoping you kept the good parts. Magic Prompt Replace outsources that to an LLM. You feed it an original prompt, a new content tag, and one of its built-in rules, and it returns a rewritten prompt through an OpenAI-compatible API. Think of it as a prompt engineer node you wire into your graph, not a text box.

It's part of the bigger "LLM as a node" pattern this pack and a lot of 2026 ComfyUI runs on: the model that writes the prompt is separate from the encoder that reads it. Here the writer is whichever OpenAI-format API you configure - local (Ollama or similar) or hosted - and the node's job is to turn your raw idea into a prompt tuned for whatever checkpoint you're about to feed.

The rules are the whole point

The rule_name dropdown ships nine presets, and they map cleanly onto real workflows:

  • Edit 指令润色 - polishing for Qwen-Image-Edit-style edit prompts
  • 自然语言润色 - natural-language cleanup for FLUX / Z-Image
  • SDXL 标签润色 - tag enhancer for the tag-vocabulary SDXL lineage (the opposite paradigm, since those models want booru tags, not prose)
  • 智能互译 - smart Chinese⇄English translation
  • 替换角色 / 替换背景 / 替换服装 - replace the character, background, or costume
  • 女转男 / 男转女 - gender swaps

So the common move is: put the thing you're changing in replace_tag, pick the rule, and let it rewrite. You can also save your own rules, which is where it becomes genuinely yours.

Inputs and outputs

  • original_prompt (STRING, multiline) - the prompt to edit
  • replace_tag (STRING, multiline) - the new content to inject
  • llm_profile - which configured LLM endpoint to call
  • rule_name - which rule the LLM follows
  • original_prompt_in (STRING, optional) - wire this and the node uses the connected string instead of the original_prompt text box, handy for chaining the output of another node

Output is a single modified_prompt (STRING). You'll run it through your CLIP encode or a new prompt box afterwards.

The robustness stuff actually matters

V1.4.1 rewrote the request layer, and the changes are the kind you notice when something breaks: configurable connect/read timeouts and automatic retries with backoff, so a transient provider hiccup doesn't kill the whole run. Errors now come back with a request ID, which makes multi-node concurrent runs actually debuggable in the logs. And the logs no longer print your API key or full prompts - a real security improvement, not a marketing bullet, and worth checking for in any LLM node you install. If you're using a slow model, raise the read timeout (the changelog suggests 180–300s) in the settings dialog.

Where people get burned

No API key, no LLM, no output. It does not run locally by default - configure an endpoint under the node settings (or the shared "Manage LLM" dialog, which is shared with the prompt box) or you'll get nothing back. Second: it's an LLM, so it can drift - the "replace character" rule may also reword your whole prompt. If you want surgical edits, keep the original short and the replace_tag explicit, and review the output before trusting it downstream. This is a prompt suggestion engine, not a precision tool.

Installing

It's part of the Magic-Assistant pack:

cd ComfyUI/custom_nodes/
git clone https://github.com/shigjfg/ComfyUI-Magic-Assistant.git
cd ComfyUI-Magic-Assistant && pip install -r requirements.txt

Restart, then find it under "✨ Magic Assistant". The openai Python package is the key dependency (it's in requirements.txt); your API provider is configured inside the node, not the repo.

Category✨ Magic Assistant

Inputs (8)

NameTypeDefaultDescription
original_promptSTRING—
replace_tagSTRING—
llm_profileCOMBO1 options: Default OpenAI
rule_nameCOMBO9 options: 🪄 Edit 指令润色 (Qwen-Image-Edit), 📝 自然语言润色 (FLUX/ZImage), 🎨 SDXL 标签润色 (Tag Enhancer), 🌐 智能互译 (Smart Translate CN⇄EN), 🔷替换角色 (Character), 🔆替换背景 (Background), +3
rewrite_backendCOMBOllmllm 使用远程 OpenAI 兼容服务;local 使用配置中心的 ComfyUI 文本编码器或 llama.cpp。
local_profileCOMBO1 options: Default Local
original_prompt_inoptSTRING—
imageoptIMAGEOptional reference image. Connected images are sent to vision-capable OpenAI-compatible models.

Outputs (1)

NameTypeDescription
modified_promptSTRING—