Nodes/ComfyUI-QING/提示词丨随机组合
ComfyUI Node

提示词丨随机组合

Wildcard-style prompt variation without the wildcard syntax

By sheengoa·Created about a year ago·Updated 20 days ago· 16
提示词丨随机组合
    • prompt
    • picked_items
    • 调试信息
    base_prompt
    pool_a
    pool_b
    pool_c
    seed-1
    pick_a0
    pick_b0
    pick_c0
    unique_picktrue
    joiner,

    The old wildcard trick - __hair__, __outfit__, let the graph roll new values every run - is still the fastest way to explore a prompt space, and it works without any __ syntax here. QING_PromptRandomizer is the QING pack's take: three text pools (one candidate per line), you say how many to pick from each, and it assembles a prompt. Fixed seed means reproducible; -1 means a roll of the dice.

    What it does

    Inputs: base_prompt (the fixed part), then three pools - pool_a, pool_b, pool_c - each a multiline box where every line is one candidate. pick_a / pick_b / pick_c (default 0 each) say how many to draw from each pool. seed (default -1, meaning "new random each time"; set any non-negative value to make a roll reproducible). unique_pick (default true) draws without replacement, and joiner (default ", ") is the separator between the base prompt and the picked items.

    Outputs: prompt (the assembled string), picked_items (what was actually drawn, tagged A:/B:/C: so you can see which pool each came from), and a debug/info string with seed, pool sizes, and pick counts.

    Mechanically it's Python's random.Random(seed) doing sample/choice - nothing exotic, which means the semantics are the familiar ones: a fixed seed always produces the same roll for the same pools.

    Where you'd reach for it

    Batch variation is the killer use: pool A = hair colors, pool B = outfits, pool C = settings, base prompt fixed. Run 30 images and every one differs; find a good combo, copy the picked_items line or lock the seed, and you can reproduce the exact prompt. It's the same idea as the wildcard lists from the prompt-engineering doc, just without the syntax layer - and it composes cleanly with the pack's QING_PromptTemplate if you want the roll inserted into a structured template.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/GAO-SHIQING/ComfyUI-QING
    cd ComfyUI-QING
    python install_dependencies.py
    

    Restart ComfyUI after. Pure stdlib random, no dependencies. Manager: search "ComfyUI-QING." (README's clone URL has a GAOSHI-QING typo - repo is GAO-SHIQING/ComfyUI-QING.)

    Things to know

    Two gotchas, one in the pools and one in ComfyUI itself. Pool math: with unique_pick on (the default), asking to pick 3 from a pool that only has 2 entries raises an error - the node refuses rather than repeats. Keep pools at least as big as your pick counts. The caching one is subtler: the node doesn't force an always-rerun (no IS_CHANGED override), and ComfyUI aggressively caches node results. With seed at -1 and unchanged inputs, a cached run can serve you the previous roll instead of a fresh one - which is the exact opposite of what you wanted from a randomizer. If your prompts aren't changing between runs, nudge an input, toggle a widget, or re-queue rather than assuming the -1 did its job.

    CategoryQING/数据工具

    Inputs (10)

    NameTypeDefaultDescription
    base_promptSTRING基础提示词
    pool_aSTRING词池A,每行一个候选
    pool_bSTRING词池B,每行一个候选
    pool_cSTRING词池C,每行一个候选
    seedINT-1-1–2147483647随机种子,-1 表示每次随机
    pick_aINT00–100词池A抽取数量(>0 时该池不能为空)
    pick_bINT00–100词池B抽取数量(>0 时该池不能为空)
    pick_cINT00–100词池C抽取数量
    unique_pickBOOLEANtrue是否不重复抽取
    joinerSTRING, 拼接分隔符

    Outputs (3)

    NameTypeDescription
    promptSTRING
    picked_itemsSTRING
    调试信息STRING