π BV Prompt Decode
Pull just the prompt sections you want out of the AST β 'style only', please
- ast
- ast
- filtered_prompt
BV Prompt Decode extracts plain text from a BV_AST - but only the categories you ask for. Feed it the AST from BV Prompt Encode, tell it which category to pull, and it hands back a clean, filterable prompt string. It's the read-side of the pack's AST prompting system, and it's where the "structure your prompt as sections" philosophy from the KB's prompt-engineering docs actually pays off.
The use case that justifies this node: you've tagged a prompt into blocks (@@style, @@subject, @@lighting). Now you want to build variants - one run with style + subject, another with subject + lighting - without maintaining three parallel prompt strings that inevitably drift out of sync. Decode does that for you: the AST is your single source of truth, and this node slices it however you need at run time.
How it works
The mechanism is straightforward category filtering over the AST tree. Text nodes carry an "active category path" (the block they're in, plus any inline spans wrapping them), and Decode matches your filter against that path. The knobs that matter:
category_filter(STRING, defaultdefault) - comma-separated categories to keep. Empty filter = everything comes back, i.e. it behaves like a plain AST-to-text renderer.mode(BOOLEAN) -any(default) matches text belonging to any of your listed categories; switch toallto require text that sits in all of them simultaneously (rarely needed, but there if you want it).inherit(BOOLEAN, default true) - include text from child/descendant categories of the ones you name. Turn it off to match only the exact category. The on/off labels in the node spell it out: "Include parent categories" vs "Only direct category".with_comments(BOOLEAN, default false) - pull the##comment nodes into the output too.prettify(BOOLEAN, default true) - a conservative cleanup pass: collapses runs of spaces, normalizes comma spacing (a,bβa, b, kills,before commas). It deliberately does not touch attention-weight syntax or other markup, so it's safe to run before a text encoder.
Outputs: ast - the same AST passed through unchanged, so you can chain Decode nodes one after another - and filtered_prompt (STRING), the extracted text.
Wiring it
BV Prompt Encode (ast) β BV Prompt Decode (ast)
BV Prompt Decode (filtered_prompt) β CLIP Text Encode
Want two variants in one graph? Two Decodes with different category_filters, each feeding its own encode. That's the whole trick - one tagged prompt, many slices.
Install & gotchas
Pack standard: ComfyUI Manager β BV Node Pack, or git clone https://github.com/BlackVortexAI/bv_nodepack into custom_nodes, restart. No models, no dependencies, no JS UI to worry about.
Gotchas: category names must match what's actually in your AST - style won't match @@style with a trailing space, and the parser's category-name rules (no spaces, [a-zA-Z0-9_-]+) apply to your filter too. An empty category_filter returns everything, which trips people who expect "no filter = nothing." And remember inherit defaults on, so if you're filtering a parent category, you're also getting its children - turn it off if that surprises you.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| ast | BV_AST | β | |
| category_filter | STRING | default | β |
| with_comments | BOOLEAN | false | β |
| inherit | BOOLEAN | true | β |
| mode | BOOLEAN | true | β |
| prettify | BOOLEAN | true | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| ast | BV_AST | β |
| filtered_prompt | STRING | β |