Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee LLM Output Cleaner
ComfyUI Node

EmAySee LLM Output Cleaner

Strip the <think> blocks out of your LLM's chat

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee LLM Output Cleaner
    • clean_text
    text

    Your reasoning model is talking to itself

    Feed a DeepSeek-style model (or anything with a thinking/reasoning phase) into a prompt encoder and you get garbage: a wall of <think>...</think> where the model reasons out loud before answering. That's not a caption, that's a diary entry. EmAySee_LLMOutputCleaner exists to fix exactly this - one text in, one clean text out, with the reasoning trace stripped.

    It's a tiny node, and it's honest about being tiny: a single regex removes everything between <think> and </think> (dot-all mode, so multi-line traces go too), then it trims leftover whitespace. That's the whole job. It slots in after any LLM output - EmAySee_LlamaVision, the pack's Oobabooga connector, whatever - and before the string hits a prompt box, a filename, or a save node.

    Inputs and output

    • text (STRING, force input) - the raw LLM output, usually wired from another node rather than typed.

    Output: clean_text (STRING) - the same text minus reasoning blocks and stray whitespace.

    That's the entire surface area. If the node ever confuses you, it's because you expected more knobs; there are none, and that's fine.

    Install

    Part of the ComfyUI_EmAySee_CustomNodes pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
    # restart ComfyUI
    

    Or find it under "ComfyUI_EmAySee_CustomNodes" in ComfyUI Manager. No dependencies, no models, no config - it's a regex in a box.

    Gotchas

    Two limits worth knowing. First, it only understands the <think> tag. If your model wraps reasoning in <thought>, [analysis], or plain paragraphs, this node won't catch it - those get piped straight through. Some models also add a "Here is the thinking process:" preamble before the trace, and the code has that cleanup commented out, so the preamble survives too; strip it with a replace node if it shows up. Second, it's whitespace-agnostic but not semantics-aware: if your caption legitimately contains the literal text <think>, it'll be removed. For the actual use case - cleaning DeepSeek-class output before it reaches a text encoder - it's exactly right, and it's one of the few genuinely useful glue nodes in a pack that otherwise skews toward "built for the author's own graph."

    CategoryEmAySee/Utils

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    clean_textSTRING