Nodes/ComfyUI-NovelAI-GENYTOOLS/NAI 正面提示词处理器
ComfyUI Node

NAI 正面提示词处理器

Chunks, random picks, and auto text blocks

By XTOGENY·Created about a month ago·Updated 4 days ago· 14
NAI 正面提示词处理器
  • prompt
  • 正面提示词
  • 摘要
chunks_json{}
seed0
render_text

The plain prompt node is a text box that does nothing but carry text. This one is the version that does the thinking: it expands shared chunks, rolls random options from a seeded list, and can hand NovelAI a proper text: block automatically. If you're generating anything in series, this is the node that stops you from editing the same prompt forty times.

What it does

NAIPositivePromptProcessorV2 takes one NAI_POSITIVE_PROMPT plus four settings - chunks_json, seed, and render_text - and outputs a processed NAI_POSITIVE_PROMPT plus a 摘要 (summary) string that tells you what it expanded and how many random choices it made.

Three mechanisms, in order:

1. Prompt Chunks (chunks_json). This is a JSON object mapping names to text:

{
  "char": "1girl, long silver hair, red eyes",
  "outfit": "school uniform, white shirt",
  "scene": "classroom, afternoon light"
}

In the prompt you write !macro:char!, !macro:outfit!, !macro:scene!. The processor substitutes the values, supports nesting up to 16 levels, and throws a clear error if you reference a chunk that doesn't exist. Now one character change is a single edit in the JSON instead of a search across a dozen prompts.

2. Randomizer. Any ||choice1|choice2|choice3|| block in the prompt picks one of the options, and the pick is seeded - same seed, same result, every time. That's the difference between this and a hand-rolled randomizer: you can lock a seed to reproduce a run, then bump it to roll new outfits without touching the prompt.

3. render_text. Whatever you type here gets appended as a proper text: "..." block. On V5 that's how NovelAI's auto text rendering works (the model actually draws text in the image), and the processor is careful not to double-wrap text you already hand-wrote. On models that don't support drawn text, the block is sent along as part of the prompt and behaves like an ordinary tag.

The summary output is the debug tool

The second output is a string like "展开 Chunk 3 个;随机选择 1 处;Seed 1234". Wire it into a text display node and you can see exactly what the prompt actually resolved to before you spend Anlas on it. On a paid API pack, that preview is worth the node alone - you never want to pay to discover a typo in a chunk name.

When to use it

  • Batch work where you swap one concept per image (the pack's own batch nodes do this).
  • Any workflow where you keep reusing the same character/scene blocks - the chunk JSON becomes your shared vocabulary.
  • V5 users who want NovelAI to render text into the image: that's the render_text input.

Install and setup

Ships in ComfyUI-NovelAI-GENYTOOLS. Manager search, or:

cd ComfyUI/custom_nodes
git clone https://github.com/XTOGENY/ComfyUI-NovelAI-GENYTOOLS.git
pip install -r ComfyUI-NovelAI-GENYTOOLS/requirements.txt

Restart, then set your NovelAI Persistent API Token under NovelAI 2.0: Persistent API Token. No models, no GPU load - and no Anlas on this node, since it only rewrites text.

Gotchas

  • chunks_json must be valid JSON, and every !macro:name! in the prompt must exist in it. The node errors before anything reaches the API, so the failure is loud, which is the good kind.
  • The seed input is your reproducibility lever. Leave it 0 for pure randomness per run, or fix it to make the random picks stable.
  • There's a negative twin (NAINegativePromptProcessorV2) with the same inputs - don't feed negative text into this node, the polarities are separate types.
CategoryNovelAI 2.0/提示词

Inputs (4)

NameTypeDefaultDescription
promptNAI_POSITIVE_PROMPT
chunks_jsonSTRING{}
seedINT00–4294967295
render_textSTRING

Outputs (2)

NameTypeDescription
正面提示词NAI_POSITIVE_PROMPT
摘要STRING