Nodes/ComfyUI-PJLatent/PJ-通配符单选
ComfyUI Node

PJ-通配符单选

Roll one random word from a list, seeded and reproducible

By pongjoo·Created 7 months ago·Updated 3 days ago· 0
PJ-通配符单选
    • 抽取文本
    词表文件发型.txt
    随机种子0

    Prompt variety without writing forty prompts is an old trick that refuses to die: keep a list of alternatives, roll one at random per run, batch it. That's the entire job of PJWildcardNode (pongjoo/ComfyUI-PJLatent, menu "PJ_Text"). It looks up one of the pack's built-in word lists, picks a random entry seeded by an integer, and hands you a single string. One word out, one wire to a text combiner or directly into your CLIP encode.

    The list of lists is the interesting part. The pack ships 41 .txt category files in its wildcards/ folder - hair styles, clothing, composition angles, actions, events, colors, and so on. The dropdown (词表文件) is built by scanning that folder, so whatever you drop in there appears in the list after a refresh. That's also the honest caveat: the bundled lists are Chinese-first - they were written for a Chinese-speaking audience (发型.txt, 手部动作.txt, 事件-健身房.txt). If you prompt in English or Danbooru tags, you'll want to add your own .txt files rather than lean on the defaults. Easy enough: the node just reads plain text files, one option per line, # for comments.

    The inputs:

    • 词表文件 - which list to pull from. It's an enum dropdown of whatever's in wildcards/.
    • 随机种子 - the seed. Same seed + same list = same pick, every time. This is what makes the "batch a seed range for variety" pattern work, and what keeps a favorite generation reproducible.

    Mechanically it's small and honest: random.Random(seed).choice(lines) over the file's non-empty, non-comment lines, reading UTF-8 with a GBK fallback (for legacy Chinese Windows text files). It returns an error string rather than raising if the file is missing or empty - so a bad path doesn't kill your queue, it quietly prints "错误: 词表文件不存在" into your prompt. Worth knowing, because that string then goes straight into the sampler if you're not watching.

    Note this node is the manual pick: you choose one list and get one roll. If you want to drop random tokens inline inside a sentence template, the same pack's PJWildcardParserNode (通配符大师) does __token__ expansion instead - they're siblings, and PJTextCombine in the same suite is the natural place to stitch whatever you rolled into a full prompt.

    Install

    Part of pongjoo/ComfyUI-PJLatent (MIT, Chinese-authored). ComfyUI Manager → search "ComfyUI-PJLatent", or:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/pongjoo/ComfyUI-PJLatent.git
    

    Restart ComfyUI. No dependencies, no models - the word lists ride inside the pack, which is also where you'd add your own. Look for PJ-通配符单选 in the node menu.

    It won't change your life if you write prompts by hand. But for seed-sweeping a subject through a set of outfits or angles - pick one word per run, batch the queue - it's a clean, reproducible way to get the variety the "bracket trick" crowd gets from {this|that}, without the parsing.

    CategoryPJ_Text

    Inputs (2)

    NameTypeDefaultDescription
    词表文件COMBO发型.txt41 options: 发型.txt, 手部动作2.txt, 装置.txt, 事件-体育.txt, 事件-乘坐交通工具.txt, 户外鞋材质.txt, +35
    随机种子INT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    抽取文本STRING