Nodes/ComfyUI-ZML-Image/ZML_追加提示词
ComfyUI Node

ZML_追加提示词

If the prompt contains 'cat', swap in your cat block — automatically

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_追加提示词
    • 文本
    • Help
    输入文本
    检测词
    预设文本
    处理模式追加

    Prompt editing is usually a manual job: you look at the prompt, decide it needs an extra block, and type it in. ZML_AppendTextByKeyword (ZML_追加提示词) makes that conditional. It watches your input text for a keyword you specify, and when it finds one, it appends - or replaces - text you've prepared. "If the prompt mentions a cat, bolt on my cat quality block. Otherwise leave it alone." That's the whole node, and it's quietly useful once you start chaining conditional prompt logic.

    What it is

    A text-transformation node from ComfyUI-ZML-Image: it takes your prompt, checks whether any of a set of detection keywords appears, and applies one of three operations. The four inputs:

    • 输入文本 (STRING) - the prompt (or any text) being examined.
    • 检测词 (STRING) - keywords, comma-separated. If any of them appears in the input, the node fires.
    • 预设文本 (STRING) - the text to append or swap in.
    • 处理模式 - the three behaviors: 追加 (append the preset to the end of the input), 替换标签 (replace only the tags that matched the keywords), and 完整替换 (throw away the input and output just the preset).

    Outputs are 文本 (the result - straight into a CLIP Text Encode) and a Help string explaining the modes, in the pack's habit.

    How it works

    The mechanism is substring matching: each keyword is checked against the input with a plain in, and any hit triggers the mode. In 替换标签 mode it does something a bit smarter - it splits the input into comma-separated tags per line and swaps out only the tags that matched your keyword list, preserving the rest of the prompt and its line structure. So 1girl, cat ears, blue hair with 检测词 cat and 预设文本 animal ears becomes 1girl, animal ears, blue hair. That respects how booru-tag prompting actually works, where tag order and exact vocabulary matter (the prompt-engineering layer has the whole story on that). 完整替换 is the blunt instrument for "detected the trigger, want a totally different prompt now."

    Install and gotchas

    Standard for the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zml-w/ComfyUI-ZML-Image
    

    or ComfyUI Manager → ComfyUI-ZML-Image, restart.

    The gotchas are all about expectations. This is exact substring matching, not fuzzy or regex - cat matches catalog and cats too, so short keywords will fire more often than you think. Keywords are comma-separated, and the node help explicitly notes that any match triggers, not "all". And 追加 just glues the preset onto the end - there's no smart comma handling, so you'll often want your preset to start with a comma or a line break to keep the tag syntax clean. The UI is Chinese; the English patch at github.com/zml-w/ZZZ_ZML_English_Patch is worth grabbing. One-person pack, no English community - the Help output and GitHub issues are your support.

    Categoryimage/ZML_图像/文本

    Inputs (4)

    NameTypeDefaultDescription
    输入文本STRING
    检测词STRING
    预设文本STRING
    处理模式COMBO追加3 options: 追加, 替换标签, 完整替换

    Outputs (2)

    NameTypeDescription
    文本STRING
    HelpSTRING