Nodes/ComfyUI-Book-Tools Nodes for ComfyUI/[Book Tools] Prompt Selector
ComfyUI Node

[Book Tools] Prompt Selector

Grabbing one prompt out of a Book Tools batch

By Big-Idea-Technology·Created 2 years ago·Updated 7 months ago· 40
[Book Tools] Prompt Selector
  • dictionary
  • STRING
selected_indexes1,2,3

BTPromptSelector is the picker half of the Book Tools prompt-batch pair. Its sibling, BTPromptSchedule, turns a list of page descriptions into a dictionary; this node pulls one entry out of that dictionary and hands it to your sampler as a plain string. If you're rendering a book one page at a time - cover, title page, chapter one, chapter two - that's the whole workflow in two nodes, and this one is where you choose which page you're on.

How it works

The node takes two inputs: dictionary (the DICTIONARY output from BTPromptSchedule) and selected_indexes. It looks up one key and returns whatever string lives there. That's it - no prompting, no fancy merging, just an indexed read from a dict.

And here's the trap that will cost you twenty minutes: the default value for selected_indexes is literally "1,2,3". That reads like a range, and the docstring even talks about "indices and ranges," but the actual code does a single lookup: dictionary.get(str(selected_indexes)). So with the default untouched, it goes looking for a key called "1,2,3", finds nothing, and returns an empty string. Your sampler runs with a blank prompt and you wonder what broke. Set it to a single number - 1, 2, 3 - and it works exactly as expected.

The one output that matters

The STRING output is what you wire into a CLIPTextEncode's text input (positive or negative, whichever side you scheduled). Because it's a plain string, you can also pipe it into anything else that eats a prompt - a LoRA stack's prompt side, a text concat node, whatever.

One structural note: DICTIONARY is a custom type, not a core ComfyUI type. That means BTPromptSchedule's output only plugs into inputs that also expect DICTIONARY - and in practice, that's BTPromptSelector's dictionary input. They're designed as a matched pair, which is convenient and also means the dictionary is useless to other node packs.

Installing

ComfyUI Manager is the easy route: Manage → Install Custom Nodes → search "ComfyUI-Book-Tools", install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/Big-Idea-Technology/ComfyUI-Book-Tools
# then restart ComfyUI

The whole pack is pure Python - Pillow, torch, numpy, all already in your ComfyUI environment. No model files, no weights to download, nothing heavy. (The README mentions a requirements.txt; the repo doesn't actually ship one, and it doesn't need to.)

Common issues

The empty-output-with-default problem above is the big one, and it's easy to confuse with a broken prompt. Beyond that: if the dictionary is empty or you ask for an index that doesn't exist, you get an empty string back rather than an error - so validate by previewing the output with a Show Text node before you burn a batch. For a real book workflow, this node pairs naturally with the BTLoop iteration counter as your page index, so each loop pass renders the next page's prompt.

Categoryselector

Inputs (2)

NameTypeDefaultDescription
dictionaryDICTIONARY
selected_indexesINT1,2,3

Outputs (1)

NameTypeDescription
STRINGSTRING