Nodes/ComfyUI-Prompt-Gallery/🎨 Prompt选择
ComfyUI Node

🎨 Prompt选择

Your prompt library, wired straight into the sampler

By Lotus0614·Created 5 months ago·Updated 7 days ago· 28
🎨 Prompt选择
    • prompts_string
    • metadata_json
    selected_prompts
    metadata{}

    If you only install one node from Prompt Gallery, this is the one. It's the interactive picker: everything you've saved in the gallery - individual prompts and whole categories - shows up right on the node, you tick what you want, and it stitches the picks into a single prompt string with weights, randomness, cycling and per-partition formatting. Think of it as the "assemble a prompt from your best bits" node, the thing that finally makes a saved prompt library useful instead of just decorative.

    How it works

    The mechanism is a bit sneaky and worth knowing, because it explains two weird things you'll notice. The node's two inputs - selected_prompts and metadata - are STRING widgets flagged hidden. You never type into them; the node's own UI writes the current selection into them, and the backend reads them back on execution. That's why the node feels like a control panel rather than a wire junction: the state lives in the frontend, travels through the graph as strings, and the node turns it into output.

    Second: the node opts out of ComfyUI's caching by returning NaN from IS_CHANGED, the standard "always rerun me" trick. That's what makes random and cycle modes possible - each run genuinely re-rolls. The cost is that everything feeding it re-executes every run, so don't be surprised if a workflow with this node skips nothing.

    The inputs and outputs that matter

    You basically don't set inputs here - you use the node's interface. Behind the scenes it's:

    • selected_prompts (hidden) - what you ticked in the UI
    • metadata (hidden, optional) - partition config: formats, weights, random/cycle settings

    And the two outputs:

    • prompts_string - the finished text. This is what you wire into your CLIP Text Encode (positive).
    • metadata_json - JSON of what was resolved, if a downstream node wants the exact selection.

    The formatting bits are where this node earns its keep. Each partition has an output format: {content} stands for the prompt itself, and {random(min,max,step)} injects a random number in that range - so ({content}:{random(0.8,1.2,0.1)}) gives you a per-run random attention weight. Weights apply SD attention syntax, wrapping a pick as (prompt:1.3) when it isn't 1.0.

    The trap: that weight wrapping is CLIP-era syntax. On LLM-encoded models - Flux 2 Klein, Z-Image, Anima - ComfyUI discards attention weights entirely, and the parentheses get passed through as literal punctuation in your prompt, which is worse than no weighting. If you're on the SDXL lineage (Illustrious, NoobAI, Pony), weights work exactly as intended. Know your encoder before you build a fancy format string.

    Random vs. cycle mode is the other choice you'll actually make: random picks N entries each run; cycle rotates through your selection one run at a time, so a batch of 8 runs walks 8 different prompts in order. Great for character-reference or style-variation batches.

    Install

    Pack-wide, so this applies to every node in it. From ComfyUI Manager, search "Prompt Gallery", or do it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Lotus0614/ComfyUI-Prompt-Gallery
    cd ComfyUI-Prompt-Gallery
    pip install -r requirements.txt
    

    Windows portable uses ..\..\python_embeded\python.exe -m pip install -r requirements.txt. No models to download - the only deps are Pillow and pyahocorasick, which just speeds up a bulk cover-backfill scan and silently falls back to a built-in if missing. Restart ComfyUI, then hard-refresh the browser (Ctrl+Shift+R). This pack's frontend caches aggressively; stale JS is the classic "why is nothing showing up."

    Common issues

    • New prompts/categories not in the picker? Refresh the page - the dropdown and picker are snapshotted when ComfyUI builds its node definitions.
    • Weights doing nothing? Check your model's encoder, per above. Not a bug in this node.
    • Workflow runs everything every time? Working as designed - always-rerun is required for random/cycle.
    • Data lives in ComfyUI/user/default/prompt_gallery/*.json; back it up before migrating ComfyUI.
    Category🎨 Prompt Gallery

    Inputs (2)

    NameTypeDefaultDescription
    selected_promptsSTRING
    metadataoptSTRING{}

    Outputs (2)

    NameTypeDescription
    prompts_stringSTRING
    metadata_jsonSTRING