Nodes/comfyui-anima-toolkit/TK 批量提示词注入
ComfyUI Node

TK 批量提示词注入

One txt file, a night of renders, no babysitting

By Ararararararaki·Created 3 months ago·Updated about 16 hours ago· 10
TK 批量提示词注入
    • preview_prompt
    prompt_files
    positive_target
    negative_target
    camera_target
    output_subfoldertrue
    groups_selection
    region_values
    camera_values
    extra_dirs

    The way most people batch is the wrong way. They put a hundred prompts in a text file, wire the file into the prompt box, and let ComfyUI chew - which works right up until you want a different camera on group seven, or you want to know which file in output/ came from which prompt.

    TK 批量提示词注入 takes the other approach: a prompt file where each entry can carry its own settings, and a server-side controller that runs the groups one after another. It's the batch node in TK Toolkit (anima-toolkit by 时运tk).

    The prompt file

    Files live in ComfyUI/input/prompts/ - or anywhere, if you fill in extra_dirs. The format is plain text:

    ## 组1 · 单人日常 · 教室窗前
    masterpiece, best quality, safe, 1girl, [角色], [通用标签...]
    相机: from the side, low angle
    
    ## 组2 · 双人 · 海边黄昏
    safe, 2girls, [角色A], [角色B], [通用标签...]
    

    Group headers accept ## 组N · 标题, 【N】标题 or a plain 01 序号 line; # starts a comment; a 相机: line belongs to that group and is stripped out of the prompt rather than fed to the encoder. One group equals one image.

    The inputs that matter

    • prompt_files - the file list, one path per line, relative to input/ or absolute. The node UI has a "选择文件…" picker and a "最新" button that grabs the newest file, plus an "auto-use latest" toggle if you generate prompt files with a script or an LLM.
    • positive_target and negative_target - where the prompts get injected. These are nodeId.inputKey strings filled in by the front-end dropdown, not something you type. Point positive_target at your CLIP text encode's text widget, and it gets rewritten per group.
    • camera_target - optionally point this at a TK 可动素体相机 node and each group's camera line goes there instead of into the prompt text.
    • output_subfolder - on by default. Each group's name overrides SaveImage's filename_prefix, so group seven's images land in their own subfolder instead of interleaving with the rest.
    • groups_selection - a JSON array of ticked group names, persisted with the workflow. Empty means run everything.
    • region_values - per-group x,y,w,h,strength in 0–1 proportions. The node injects a ConditioningSetAreaPercentage for that group, so you can lock a subject to a region of the canvas. This is the same idea as regional prompting, minus a separate extension: give the character a box and stop it wandering.
    • camera_values - per-group camera overrides keyed by group, as natural language, a preset name, or raw px,py,pz,roll. These beat whatever the file's 相机: line says.
    • extra_dirs - extra absolute directories the file picker and "latest" scan.

    Output is preview_prompt, a STRING carrying the first selected group's text - wire it to a text node if you want a single test run before committing to forty.

    How the batch runs

    This is the part that separates it from a loop node. Execution is handled by a server-side batch controller: one group runs, then the next is queued, and the browser isn't in the loop. Each job gets its own minted prompt_id so status accounting is exact rather than string-matching. The node panel shows progress live, and you can pause, resume, retry failures, skip a single group or cancel the batch. Job lists persist to data/batches/, so restarting ComfyUI doesn't lose an unfinished run - you can resume it from the node.

    Kick off a batch, come back later. The old design - a browser hijacking the queue - is why the pack rewrote this.

    It doesn't generate images by itself

    Worth being blunt about. This node injects text into an existing workflow. If your graph is a working single-image pipeline, it will drive that pipeline group by group; if it isn't, you get forty identical errors very efficiently. Build and validate the graph with one group first.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/Ararararararaki/comfyui-anima-toolkit
    # restart ComfyUI
    

    ComfyUI Manager: search TK Toolkit (anima-toolkit). Required packages: aiohttp, requests. Under TK/batch in the node menu.

    Gotchas

    Targets must be real text inputs. If positive_target points at a node whose text can't be overwritten in the queued prompt, groups will run with whatever was in the box. Set it from the dropdown, not by hand.

    Region values are proportions, not pixels. 0.5,0.5,0.5,0.5,1.0 is the right-hand half at full strength. Pixel values will silently do something unhelpful.

    Extra directories beat input/ for LLM-written files. If you're generating prompt files with the bundled anima-prompt-writer skill or any script that writes elsewhere, either write into input/prompts/ or list the output folder in extra_dirs, otherwise "latest" will keep grabbing a stale file and you'll blame the queue.

    CategoryTK/batch

    Inputs (9)

    NameTypeDefaultDescription
    prompt_filesSTRING提示词文件列表;支持 ## 组N / 【N】标题 / 01 序号 三种分组格式。
    positive_targetSTRING注入正向提示词的目标文本节点(nodeId.inputKey,前端下拉自动填写)。
    negative_targetSTRING可选:注入负向提示词的目标文本节点。
    camera_targetSTRING可选:指定一个相机节点(TK 可动素体相机)注入对应机位词;旧 TK 相机控制节点已退役。
    output_subfolderBOOLEANtrue按组名覆盖 SaveImage 的 filename_prefix,每组图片存到独立子目录。
    groups_selectionSTRING已勾选组名的 JSON 数组,随工作流持久化;留空=全部。
    region_valuesSTRING每组区域参数 x,y,w,h,强度(0~1 比例),随工作流持久化;队列时自动注入 ConditioningSetAreaPercentage。
    camera_valuesSTRING每组独立机位:{组键: 机位描述}(自然语言/预设名/px,py,pz,roll),随工作流持久化;优先级高于文件「相机:」行。
    extra_dirsSTRING附加提示词搜索目录(每行一个绝对路径)。AI 写词落盘到 input 之外时填这里,「最新」/自动最新/递归浏览都会覆盖。

    Outputs (1)

    NameTypeDescription
    preview_promptSTRING