Nodes/AI4ArtsEd Nodes/AI4ArtsEd Promptsafety Switch
ComfyUI Node

AI4ArtsEd Promptsafety Switch

A filter that can tell a scary prompt to go away — and the kitten that replaces it

By joeriben·Created about a year ago·Updated 7 months ago· 1
AI4ArtsEd Promptsafety Switch
    • filtered_prompt
    prompt
    filter_leveloff
    model
    api_key
    unload_modelno
    model_override

    The AI4ArtsEd Promptsafety Switch sits between a prompt and your image model and runs it through an LLM safety filter. Turn it to kids and a prompt about a demonic entity doesn't just get toned down - it gets replaced wholesale by a small kitten in front of a computer screen displaying "Sorry, too scary." That's not a metaphor; that's the literal default behavior coded into the node, and it's the most memorable thing in this pack.

    The use case is real even if the presentation is charming: if you're running ComfyUI in a classroom or youth-arts context (which is this pack's whole raison d'être - it's built by an arts-education research project), you want a semantic gate between a student's text and the sampler. This is an LLM-based filter rather than a keyword list, so it can catch meaning - a prompt about graphic violence or adult horror - not just banned words.

    How it works

    The filter_level dropdown picks one of three behaviors:

    • off - passthrough, prompt untouched.
    • youth - if the prompt is problematic, an LLM transforms it: darker themes get modulated into symbolic, restrained, ambiguous forms rather than suppressed. The instructions explicitly forbid falling back to "cute/chibi" or horror aesthetics - the goal is keeping imaginative complexity while dropping the terror.
    • kids - if the prompt would genuinely scare a child, discard it and output the kitten prompt. Otherwise, soften it: add "drawing from a children's book" before risky tokens, and semantically harmonize loaded words (despair → sadness, killing → very angry). The instructions also warn the model not to output negations like "no blood," because negative constructions can backfire with SD 3.5.

    The model dropdown defaults to local/mistral-nemo:latest (auto-detected from your Ollama install) with a handful of OpenRouter fallbacks. The node hits Ollama at localhost:11434 or OpenRouter with your key. There's an optional model_override string input if you want to swap models without touching the dropdown.

    Input: prompt (the text to filter). Output: filtered_prompt - the original, the transformed version, or the kitten.

    A genuinely thoughtful detail: if the filter errors - Ollama down, no API key - it doesn't fail open with the unfiltered prompt. It outputs a safe fallback ("Filter error! Check your OLLAMA server or API credentials."). For a safety node, fail-closed is the right instinct.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/joeriben/ai4artsed_comfyui_nodes
    # restart ComfyUI
    

    Or search "AI4ArtsEd" in ComfyUI Manager. For the default local path you need Ollama running with a model (ollama pull mistral-nemo); otherwise use an OpenRouter model with a key.

    Common issues

    Filter is off but you expected filtering. The default is off - you have to pick a level. This is deliberate (you don't want a filter you forgot about rewriting every prompt), but it trips people who wire it in expecting protection by default.

    Everything becomes the kitten. On kids, an over-cautious LLM will classify borderline prompts as too scary. If your legit content keeps getting replaced, that's the model's judgment call - try youth instead, or a stronger model. It's an LLM filter; calibration is part of the job.

    Fail-closed can bite. If the filter errors on every run, you get the "Filter error!" robot prompt, not your input. Fix the Ollama connection or key - that's the intended signal.

    It's one of the few nodes of its kind, and it's thoughtfully built for its niche: an LLM-gated safety layer for youth art contexts, with sane defaults and a fail-closed posture. If you're generating for kids, it's worth a serious look. If you're not, off is where it stays.

    CategoryAI4ArtsEd

    Inputs (6)

    NameTypeDefaultDescription
    promptSTRING
    filter_levelCOMBOoff3 options: off, youth, kids
    modelCOMBO7 options: local/mistral-nemo:latest, openrouter/anthropic/claude-3.5-sonnet [multilingual / $0.80/$4.00], openrouter/anthropic/claude-3-haiku [multilingual / $0.80/$4.00], openrouter/google/gemini-pro-1.5 [translator / $1.25/$10.00], openrouter/meta-llama/llama-3-70b-instruct [rule-oriented / $0.59/$0.79], openrouter/mistralai/mistral-large [reasoning / $0.40/$2.00], +1
    api_keySTRING
    unload_modelCOMBOno2 options: no, yes
    model_overrideoptSTRING

    Outputs (1)

    NameTypeDescription
    filtered_promptSTRING