ComfyUI Node

Prompt

Wildcards, weighted mixes, file loading, token counts — and a local LLM rewrites your prompts

By IxMxAMAR·Created 4 months ago·Updated about a month ago· 0
Prompt
    • prompt
    • negative
    • all_prompts
    • token_count
    modellm_enhance_prompt
    theme(use pack default)
    prompts
    index0
    path
    seed-1
    text
    wildcards_json{}
    a
    weight_a1.00
    b
    weight_b1.00
    template
    vars_json{}
    dedupetrue
    positive
    presetrealistic
    separator,
    prompt
    modelllama3.2
    base_urlhttp://127.0.0.1:11434
    styledetailed
    timeout_seconds60
    system_prompt

    Prompt tooling is a whole ecosystem of separate packs, and the Prompt node from Utility-MegaPack tries to fold the useful 80% of it into one dropdown. Ten modes: pick a prompt from a batch by index, load prompts from a .txt/.csv file, expand __wildcards__, weight-mix two prompts, render a Jinja template, clean up a prompt (collapse whitespace, fix double commas, dedupe phrases), auto-build a negative, join a list of prompts, count tokens, and - new in v0.3 - llm_enhance_prompt, which sends a rough prompt to a local LLM and gets back a proper one.

    Which modes are actually worth reaching for? wildcard_expand and prompt_from_file are the two that replace dedicated wildcard and prompt-batch packs for most people. token_count is genuinely useful because it gives you a number to hang a workflow decision off of. And if you already run Ollama or LM Studio locally, llm_enhance_prompt is a cheap way to get an LLM in the loop without shipping your prompts to a cloud API.

    How it works

    Every mode is a registered operation on the same node - pick mode, and the relevant widgets show themselves. Outputs are prompt, negative, all_prompts (a LIST), and token_count (INT); only the slots your mode fills are live.

    • wildcard_expand replaces each __key__ in text with a random pick from wildcards_json[key] - pools are defined in a JSON widget, not as files in a wildcards folder like some packs.
    • prompt_mix emits (a:weight_a) (b:weight_b), the Auto1111 attention syntax. Keep in mind that syntax only does something on CLIP-encoded models - LLM-encoded models read those parentheses as literal punctuation.
    • negative_auto_build takes a preset (realistic / anime / landscape / none) and emits a stock negative; the positive input is accepted for pairing but not modified.
    • token_count is a word-plus-punctuation heuristic, not a real CLIP tokenizer - treat it as approximate, and warn at the 75/150 boundaries if you're targeting SD 1.5/SDXL CLIP.
    • llm_enhance_prompt hits base_url (default http://127.0.0.1:11434, Ollama) with your prompt, a style directive, and optional system_prompt. It tries Ollama's /api/chat first and falls back to the OpenAI-style /v1/chat/completions endpoint, so LM Studio and llama.cpp server work too.

    Installing it

    Ships with the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/IxMxAMAR/ComfyUI-Utility-MegaPack
    

    Restart ComfyUI, or use ComfyUI Manager → "Utility-MegaPack". No model downloads for the prompt ops themselves. llm_enhance_prompt does need a running local LLM server and its model (e.g. Ollama with llama3.2), but that's your machine, not the node's.

    Where people get tripped up

    The local-LLM mode is where beginners trip. The pack blocks HTTP to localhost by default as an SSRF safeguard, and this node respects that - so if llm_enhance_prompt throws a "http to internal address blocked" error, set UTILITY_MEGAPACK_ALLOW_INTERNAL_HTTP=1 in your environment and restart. That env var is the escape hatch for exactly this use case. Also set a realistic timeout_seconds; first-time model loads on Ollama can take a while. And don't expect the token counter to match your text encoder's real tokenizer to the digit - it's a rough ruler, and on LLM-encoded models the whole 77-token mental model is obsolete anyway. Where people get burned most often, though, is the wildcard JSON: if the pool key has a typo, the __key__ is just left in the text, silently.

    CategoryUtility-MegaPack

    Inputs (24)

    NameTypeDefaultDescription
    modeCOMBOllm_enhance_prompt10 options: llm_enhance_prompt, negative_auto_build, prompt_batch_pick, prompt_clean, prompt_from_file, prompt_join_list, +4
    themeCOMBO(use pack default)17 options: (use pack default), (use ComfyUI default), cyberpunk, minimalist, glassmorphic, retro_terminal, +11
    promptsoptSTRING
    indexoptINT0
    pathoptSTRING
    seedoptINT-1-1–4294967295
    textoptSTRING
    wildcards_jsonoptSTRING{}
    aoptSTRING
    weight_aoptFLOAT1.000–5
    boptSTRING
    weight_boptFLOAT1.000–5
    templateoptSTRING
    vars_jsonoptSTRING{}
    dedupeoptBOOLEANtrue
    positiveoptSTRING
    presetoptCOMBOrealistic4 options: realistic, anime, landscape, none
    separatoroptSTRING,
    promptoptSTRING
    modeloptSTRINGllama3.2
    base_urloptSTRINGhttp://127.0.0.1:11434
    styleoptCOMBOdetailed5 options: detailed, cinematic, photoreal, concept_art, minimal
    timeout_secondsoptINT605–600
    system_promptoptSTRING

    Outputs (4)

    NameTypeDescription
    promptSTRING
    negativeSTRING
    all_promptsLIST
    token_countINT