Nodes/ComfyUI-ZMongo/10 Best Variant Selector
ComfyUI Node

10 Best Variant Selector

You made 10 prompts with an LLM — now pick the winner — ZMongo 10 Best Variant Selector

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
10 Best Variant Selector
    • positive_prompt
    • negative_prompt
    • score
    • json
    variants_json{}
    fallback_prompt
    refresh_token

    10 Best Variant Selector is the glue node that takes a pile of LLM-generated prompt variants and hands you the one judged best - split out into positive_prompt, negative_prompt, and a score. It's part of ZMongo's text-agent layer, and it exists for the workflow that goes: "have an LLM evolve my prompt into N versions, score them, use the winner."

    Why would you want that? Prompt evolution is a real pattern in this corner of the ecosystem: generate a handful of prompt candidates, rank them against some criterion, and only feed the strongest into the sampler. That's wasted effort if you then have to manually read JSON and copy the winner into a text node. This node automates the "extract the best" step.

    How it works

    It takes variants_json and digs out the best prompt, its negative prompt, and its score. The code is deliberately tolerant of the shape you feed it: it accepts either a raw evolution object or the full wrapper a "Prompt Evolver" node produces (it checks for data.evolution and unwraps it), so you can usually connect an evolver's output directly.

    Outputs:

    • positive_prompt - the winning prompt, ready for a CLIP Text Encode node.
    • negative_prompt - the winner's negative, if the variants carried one.
    • score - a float, the winner's score from the evolution.
    • json - the full response payload if you want provenance.

    If nothing usable is found, fallback_prompt becomes the positive_prompt output - your safety net so a failed evolution doesn't blank the graph. There's a refresh_token optional input for the pack's cache plumbing; ignore it on a first pass.

    The inputs that matter

    • variants_json - required. The evolution output, either raw or wrapped.
    • fallback_prompt - what to emit when the JSON has no usable best variant.

    That's it. No session, no database call - pure local extraction. (Note: it doesn't run the evolver or score anything itself; it just reads the score that's already in the JSON.)

    Install

    Standard pack install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo
    cd ComfyUI-ZMongo
    pip install -r requirements.txt
    

    or ComfyUI Manager → "ComfyUI-ZMongo" → restart. It's a text-agent node, so if you're feeding it evolver output that came through ZMongo's Gemini nodes, you'll also want a session configured - but this node itself doesn't need one.

    Troubleshooting

    • positive_prompt comes back as fallback_prompt - the variants JSON didn't match the expected shape. Wire json into a preview and check: it should contain a best entry with the prompt (and optionally negative/score), or sit under data.evolution. If your evolver uses different key names, you'll want 99 JSON Pick instead.
    • Score of 0 or missing - the variants carried no score field. The node defaults gracefully; the prompt still comes through.
    • Everything works but it's always the same prompt - check the evolver side; this node faithfully reports what's in the JSON.

    Best Variant Selector is a small node with a narrow job, but it's the thing that makes "generate a bunch, use the best" workflows actually automatic instead of a manual copy-paste chore.

    CategoryZMongo/07 Text Agents/Prompt Agents

    Inputs (3)

    NameTypeDefaultDescription
    variants_jsonSTRING{}
    fallback_promptoptSTRING
    refresh_tokenoptSTRING

    Outputs (4)

    NameTypeDescription
    positive_promptSTRING
    negative_promptSTRING
    scoreFLOAT
    jsonSTRING