Nodes/Text Gen Nodes/Refine Text
ComfyUI Node

Refine Text

Tweak the LLM's prompt without re-paying for it

By cora-clanker·Created 4 months ago·Updated 3 months ago· 1
Refine Text
    • text
    lockfalse
    edited_text
    text

    This is the node you didn't know you needed until you've re-rolled an LLM-generated prompt five times and watched the API calls add up. Refine Text is a passthrough with a manual override, designed for exactly one workflow: Prompt Enhancer → Refine Text → your KSampler. It captures the enhanced prompt into an editable field, lets you fix it, and reruns the image side without firing the LLM call again.

    Here's the trick that makes it worthwhile. ComfyUI caches node outputs when the inputs are unchanged - so once the enhancer has produced its text, rerunning with your edit does not re-hit the API. You iterate on the prompt text, the seed, the sampler, whatever, without spending another token or another request on the model. Prompt work is iterative by nature; you want the first good image out of ten, and this node stops you from paying for all ten rewrites to get there. It also works with any string source, not just this pack's nodes - anything that emits a text wire.

    How it works

    The node sits between an upstream string and your downstream consumers. With lock off, it passes the upstream text straight through and repopulates the editable widget after every run - think of it as a live readout. The moment you type in the widget, lock flips on automatically, and now the node outputs your edited text and ignores upstream entirely. Untick lock and it resyncs from the upstream value.

    There's a genuinely thoughtful state machine behind this, and it's unit-tested JavaScript: clearing the field while unlocked deliberately keeps lock off (so the next run resyncs instead of stranding you on empty), and both the lock state and your edits are saved into the workflow JSON, so reloading a workflow restores your tweak. The warning color isn't persisted, though.

    The inputs that matter

    • text (optional, socket-only) - the upstream string. You can't type here; it's a wire. Typical source: Prompt Enhancer's output.
    • lock (checkbox) - on means "output my edit", off means "pass through and refresh".
    • edited_text (multiline) - the editable capture. Typing here auto-locks.

    Output is a single text string, and it's whatever your lock state says it should be.

    Install

    Same pack, same story. ComfyUI Manager → search "Text Gen Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cora-clanker/comfyui-textgen-nodes
    

    Restart. Only dependency is requests (already bundled with ComfyUI), and note this pack targets the Nodes 2.0 (V3) API - you need a ComfyUI build that ships comfy_api.latest or the nodes won't appear at all.

    Where people get burned

    • The orange title bar. That's the stale-lock warning, and it's the one thing that confuses everyone on first use. If you tweak the enhancer's style or model and rerun while lock is on, the upstream value changes but your node keeps outputting the old edited text. The title bar turns orange and a warning lands in the browser console: upstream produced new text while lock is on. Untick lock to resync and clear it.
    • A stray keystroke locks you in. Auto-lock is the feature, but it also means one accidental character in the field freezes the output to your edit. If reruns suddenly ignore new upstream text, check the lock box first.
    • Thinking it's a textgen node. It's not - it does no LLM calls, makes no network requests, and needs no API key. If it's in your graph, nothing here should be hitting an endpoint.

    It's a small node with a narrow job, and that's fine. There's real craft in a passthrough that remembers your edit, warns you when it goes stale, and never once touches your wallet.

    Categorytext

    Inputs (3)

    NameTypeDefaultDescription
    lockBOOLEANfalseWhen on, output the edited text below instead of the upstream input. Auto-engages when you type in the widget.
    edited_textSTRINGEditable copy of the upstream text. Auto-populated after each run while unlocked; freely edited while locked.
    textoptSTRINGUpstream text. Socket-only; wire from Prompt Enhancer or any string source.

    Outputs (1)

    NameTypeDescription
    textSTRING