ComfyUI Node

Text Random

Roll a random prompt from up to five options

By wwsmiao·Created 4 months ago·Updated 4 months ago· 0
Text Random
    • result
    option_a
    option_b
    count1
    option_c
    option_d
    option_e
    seed0

    TextRandom is the node that turns "I can't decide between five prompts" into "I'll run it a few times and see." You give it up to five option_* strings, and it picks one or more of them, with an optional seed to make the pick reproducible. It's the wwdm-aicd pack's answer to wildcard-style prompt rotation, minus any fancy syntax.

    The inputs that matter: option_a and option_b (required, both multiline), option_c/d/e (optional), count (default 1), and seed (default 0). count decides how many options come back: 1 picks one, more picks that many, and 0 returns all of them shuffled. Only non-empty options are considered - blank fields are skipped, so you can leave option_c through option_e unused and it just works. Output is a STRING list, which is worth remembering: even a single pick comes back as a one-element list, so it wires into ListOps or TextMultiConcat more naturally than into a plain text field.

    The seed is the whole game for reproducible workflows. With seed at 0, it uses Python's global random - genuinely random, and different each run. Set a non-zero seed and the pick is deterministic, which means you can fix a prompt choice in place for a reproducible generation, then bump the seed to explore. That's the pattern for "same composition, different subject" sweeps.

    Here's the gotcha, and it's a real one: the node doesn't implement ComfyUI's IS_CHANGED hook, which is the mechanism that forces a node to re-run every time. The plumbing layer's rules are blunt about this - any node that must fire each run (a random picker among them) needs that hook, and this one doesn't have it. What that means in practice: with seed: 0 and unchanged inputs, ComfyUI's cache can hand you back last run's pick instead of rolling a new one, which makes the "random" feel sticky and confusing. The workaround that actually works: drive the pick from something that changes - convert the seed to an input and step it, or set a fixed seed and change it deliberately. Then it's predictable in the good way. It's a small omission from a brand-new pack, and the fix (declare the node changed) is a few lines any contributor could add.

    Install is the pack standard:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wwsmiao/comfyui-wwdm-aicd.git
    

    Restart ComfyUI, look under wwdm-aicd. Stdlib only; no requirements.txt in the repo despite what the README's install section implies. README and source comments are in Chinese; widgets are English.

    Best use: feeding random subjects or styles into a prompt assembly chain - pair it with TextMultiConcat's cross mode and you can roll a subject and a style independently and get all four combos, or keep it single and let it pick one per run. Just set your seed the way you'd treat the KSampler's: lock it when you find a good one.

    Categorywwdm-aicd

    Inputs (7)

    NameTypeDefaultDescription
    option_aSTRING
    option_bSTRING
    countINT10–100
    option_coptSTRING
    option_doptSTRING
    option_eoptSTRING
    seedoptINT00–999999

    Outputs (1)

    NameTypeDescription
    resultSTRING