Nodes/BV Node Pack/πŸŒ€ BV Prompt Category Switch
ComfyUI Node

πŸŒ€ BV Prompt Category Switch

Enable or disable prompt sections by category, without touching the text

By BlackVortexAIΒ·Created 8 months agoΒ·Updated a day agoΒ· 6
πŸŒ€ BV Prompt Category Switch
  • ast
  • ast
  • report
β—„enable_categoriesβ–Ί
β—„disable_categoriesβ–Ί
β—„inherittrueβ–Ί
β—„modetrueβ–Ί

BV Prompt Category Switch toggles whole prompt categories on and off directly on the AST - no string parsing, no text surgery. Feed it the AST from BV Prompt Encode, tell it what to keep (enable_categories) and what to kill (disable_categories), and it returns a pruned AST plus a report of what got removed.

This is the node that makes the pack's "no fragile string parsing" tagline real. Think about what you're doing without it: conditionally removing the @@style block from a prompt usually means string find/replace, which breaks the moment a category name shows up inside another word or the formatting isn't byte-identical. Here the parser already did the hard work - the AST knows exactly which text nodes belong to which category - so switching is a tree operation, not a regex gamble.

It slots right into the 2026 block-prompting pattern the KB documents: one master prompt, and the switch decides which sections of it exist for a given run. Want the landscape prompt but not the portrait lighting section? Switch the lighting category off.

How it works

The backend walks the AST and prunes text and comment nodes based on two lists: enable_categories (keep only these) and disable_categories (always remove these). Three rules are worth internalizing:

  • Empty enable list = keep everything - enable is a filter only when it's non-empty.
  • Disable wins - if a category is in both lists, it's removed.
  • Structure is preserved - the category block nodes stay in the tree even when emptied, so the AST keeps its shape and downstream renderers don't fall over.

Inputs: ast (BV_AST), enable_categories (STRING, comma-separated), disable_categories (STRING, comma-separated), inherit (BOOLEAN, default true - include children of the categories you name), and mode (BOOLEAN - any/all matching, same semantics as BV Prompt Decode).

Outputs: ast - the pruned tree, wire it into BV Prompt Decode or on to your encoder - and report (STRING), a human-readable summary:

[BV Category Switch]
enable: style
disable: (none)
inherit: True
mode: any
kept_text: 12 | removed_text: 4
kept_comment: 0 | removed_comment: 1

That report is the underrated feature: it tells you, per run, exactly what got filtered, which is gold when a workflow suddenly renders a blank prompt.

Wiring it

BV Prompt Encode (ast) β†’ BV Prompt Category Switch (ast) β†’ BV Prompt Decode β†’ CLIP Text Encode

Drive enable_categories/disable_categories from a text input or a BV Dynamic Combo and you've got an interactive prompt-section selector.

Install & gotchas

Pack standard: ComfyUI Manager β†’ BV Node Pack, or clone https://github.com/BlackVortexAI/bv_nodepack into custom_nodes, restart. No models, no deps, no JS.

Gotchas: this node prunes the AST - it does not produce plain text, so you still need a Decode (or the Encoder's cleaned output) before a text encoder. Categories are comma-separated; spaces around commas are trimmed, but a stray comma makes an empty entry which is simply ignored. And the structural-preservation rule cuts both ways: empty blocks staying in the tree is good for stability, but it means the category structure survives even when its content is gone.

CategoryπŸŒ€ BV Node Pack/prompting

Inputs (5)

NameTypeDefaultDescription
astBV_ASTβ€”
enable_categoriesSTRINGβ€”
disable_categoriesSTRINGβ€”
inheritBOOLEANtrueβ€”
modeBOOLEANtrueβ€”

Outputs (2)

NameTypeDescription
astBV_ASTβ€”
reportSTRINGβ€”