Nodes/OllamaTools for ComfyUI/?? Prompt Compiler (pos/neg/constraints)
ComfyUI Node

?? Prompt Compiler (pos/neg/constraints)

From 'woman on a balcony, sunset' to a full SDXL prompt — with negatives, offline

By max-dingsda·Created about a year ago·Updated 5 months ago· 4
?? Prompt Compiler (pos/neg/constraints)
    • positive_prompt
    • negative_prompt
    • constraints
    prompt
    use_llmtrue
    modelnemotron-mini:4b
    cleanup_outputtrue
    temperature0.25
    timeout_sec120

    Type woman on a balcony, sunset, elegant and get back a vivid scene prompt, a strict list of artifact negatives, and spatial constraints - all generated by a local LLM in Ollama. That's Prompt Compiler (pos/neg/constraints), the package's flagship node, and it exists because the author got tired of LLM nodes with forty settings. This one has five, and three of them you can ignore.

    It's aimed squarely at SDXL-lineage checkpoints. That matters, because the whole "negative prompt is dead" thing you hear in 2026 is only true for the newest LLM-encoded models - negative prompting is still very much alive on Illustrious, Pony, and every SDXL finetune. So a node that hands you a proper negative prompt is genuinely useful if that's what you run.

    How it works

    The node ships a long system instruction to Ollama's /api/generate with format: json, telling the model to act as a strict prompt compiler: re-express your idea as a complete scene (subject + environment + time/lighting + viewpoint), write a negative list of at least 10 common artifacts, and produce only visual/geometric constraints - no "photography advice," no content bans you didn't ask for. The response is parsed as JSON, with a fallback that hunts for the first {...} block if the model wraps it in markdown.

    Two built-in safety nets are worth knowing about. If the model returns empty negatives or constraints, the node substitutes hard defaults rather than giving you nothing. And cleanup_output strips <think>...</think> blocks - that's for deepseek-r1, a reasoning model that will happily emit a page of chain-of-thought before its answer.

    The inputs that matter

    • prompt - your raw idea. Multi-line, freeform. Keep it to a sentence or two; the whole job of the node is to inflate it.
    • use_llm - the one toggle everyone sleeps on. Default true. Flip it off and the node becomes a pass-through: your prompt comes back unchanged as positive_prompt, negatives and constraints come back empty. Handy for A/B testing whether the LLM pass is actually helping.
    • model - dropdown: nemotron-mini:4b (default), mistral:latest, zephyr:latest, llama3.2:latest, deepseek-r1:8b, ministral-3:latest, gpt-oss-fast:latest. The default is small and fast - a good starting point. If you have the VRAM/patience, deepseek-r1:8b writes noticeably richer scenes but is slow and likes to think out loud (hence the cleanup toggle).
    • temperature - default 0.25, range 0–1.5. Low is right here; you want the compiler to be deterministic, not creative with your negatives.
    • timeout_sec - default 120. The one that bites. Bigger reasoning models on CPU can blow past this, and you get an [OLLAMA ERROR] string in the output instead of a prompt.

    Outputs - three strings, and they wire exactly like they sound:

    • positive_prompt → the positive input of a CLIPTextEncode / CLIPTextEncodeSDXL.
    • negative_prompt → the negative input of that same encoder.
    • constraints → composition rules like "single main subject; centered composition." These aren't negatives - wire them into your positive prompt text, or combine them into the positive encode. The demo workflow routes them loosely; it's your call, and that's fine.

    The demo shows the full loop: booster → CLIP text encodes → KSampler → image.

    Installing it

    Same pack, same path: ComfyUI Manager (search OllamaTools) or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/max-dingsda/OllamaTools.git
    

    Restart ComfyUI, install Ollama, and pull the model you want:

    ollama pull nemotron-mini:4b
    

    Dependencies are just requests and Pillow - nothing heavy, no torch conflicts. The heavy part is Ollama itself, and that's a separate install.

    Where people get burned

    Most failures here are Ollama failures: it's not running (tray app on Windows, ollama serve on Linux), or the model isn't pulled. Both surface as that [OLLAMA ERROR] in the positive output. A JSON parse failure is the other classic - it returns the raw model text so you can see what went wrong, which is at least honest. And a warning: LLM-written negatives are usually decent, but read them once before you rely on them - a model that ignores its own instruction will happily include the thing you're trying to suppress. Treat the output as a strong draft, not gospel.

    CategoryOllamaTools

    Inputs (6)

    NameTypeDefaultDescription
    promptSTRING
    use_llmBOOLEANtrue
    modelCOMBOnemotron-mini:4b7 options: nemotron-mini:4b, mistral:latest, zephyr:latest, llama3.2:latest, deepseek-r1:8b, ministral-3:latest, +1
    cleanup_outputBOOLEANtrue
    temperatureFLOAT0.250–1.5
    timeout_secINT1205–600

    Outputs (3)

    NameTypeDescription
    positive_promptSTRING
    negative_promptSTRING
    constraintsSTRING