Nodes/Spellcaster Nodes/Spellcaster Prompt Enhance (LLM)
ComfyUI Node

Spellcaster Prompt Enhance (LLM)

Let a local LLM rewrite your prompt — and write tags for SDXL, sentences for Flux

By laboratoiresonore·Created 5 months ago·Updated 3 months ago· 1
Spellcaster Prompt Enhance (LLM)
    • enhanced_prompt
    prompt
    arch_keysdxl
    enhancetrue
    llm_urlhttp://127.0.0.1:5001
    is_negativefalse

    Prompt style is now model-dependent, and the split is brutal. SDXL and Illustrious reward comma-separated booru tags with a quality prefix; Flux and Klein respond to natural-language sentences, and quality-tag spam like masterpiece, best quality is actively wasted on them. If you switch between the two families, you're maintaining two prompt vocabularies. SpellcasterPromptEnhance hands your short prompt to a local LLM and lets it do the rewriting per architecture - tags for one family, prose for the other.

    It's the second node in the ComfyUI-Spellcaster chain: SpellcasterLoader outputs an arch_key, this node reads it and the prompt, and spits out an enhanced_prompt string you feed into a normal CLIPTextEncode.

    How it works

    Under the hood it delegates to the pack's enhance_prompt() - the same single source of truth the GIMP and Darktable plug-ins use, so the prompt-engineering lives in one place. Each architecture has a written profile: SD 1.5/SDXL/Illustrious get "comma-separated tags, quality prefix required" instructions; Flux Dev gets "flowing paragraph, 80–150 words, no quality tags"; Klein gets "concise natural language, 60–100 words"; Chroma follows the Flux 2 family style. The LLM receives your prompt plus the profile as its instructions.

    Two deliberate design choices worth knowing:

    • It talks to an external LLM server, not ComfyUI LLM nodes. The code comments explain why: running inside a workflow and submitting a nested ComfyUI workflow would deadlock the queue. So it uses plain HTTP to KoboldCpp, Ollama, or any OpenAI-compatible server.
    • Graceful fallback. If the LLM is offline, unreachable, or times out, it returns your original prompt unchanged. The node never hard-fails your workflow because the model server hiccuped.

    The inputs that matter

    • prompt - your rough idea. "cat sleeping in sunlight" is enough.
    • arch_key - from the Loader. This is the whole trick: the node picks tag-style vs natural-language from it. Don't leave it at the sdxl default while generating Flux.
    • llm_url - default http://127.0.0.1:5001, which is KoboldCpp's usual port. If you run Ollama (default http://127.0.0.1:11434), you'll change this.
    • enhance - boolean, default on. Flip it off to pass the prompt through untouched (handy for A/B comparing what the LLM is actually adding).
    • is_negative - default false. Turn it on and the LLM is told to produce a negative-prompt-style output instead (bad-light / worst-quality vocabulary for the tag family, "avoid" phrasing for the prose family).

    The one output, enhanced_prompt (STRING), wires straight into CLIPTextEncode's text input - the same input where your hand-written prompt would have gone.

    Install

    Same pack as everything else in the Spellcaster chain - one install covers all four main nodes plus the private crypto extras.

    cd ComfyUI/custom_nodes
    git clone https://github.com/laboratoiresonore/ComfyUI-Spellcaster.git
    

    or search "Spellcaster" in ComfyUI Manager. Restart, and note that this is the one node in the pack that needs a separate piece of software running (a local LLM server), not just the node itself.

    Where people get burned

    The default URL is KoboldCpp's, so if your first run with Ollama silently returns your prompt unchanged, that's not a bug - the node just couldn't reach 5001 and fell back. Point llm_url at your server and it starts working. The other gotcha is expectations: this is prompt enhancement from a local model, not a magic rewrite that fixes composition. A small 4B model will produce serviceable tags and prose, not art direction. The profiles are tuned (the pack's audit notes it keeps tag output pure comma-separated for the tag families), but if your LLM is weak, garbage in, slightly nicer garbage out.

    CategorySpellcaster

    Inputs (5)

    NameTypeDefaultDescription
    promptSTRINGInput prompt to enhance.
    arch_keySTRINGsdxlArchitecture key (from Spellcaster Loader).
    enhanceoptBOOLEANtrueEnable/disable LLM enhancement.
    llm_urloptSTRINGhttp://127.0.0.1:5001LLM server URL (KoboldCpp, Ollama, or OpenAI-compatible).
    is_negativeoptBOOLEANfalseOptimize as a negative prompt instead.

    Outputs (1)

    NameTypeDescription
    enhanced_promptSTRING