Nodes/comfyui_pilcothink_VisionSLM/Merge Texts With Gap
ComfyUI Node

Merge Texts With Gap

Six text boxes, one string, however many blank lines you want

By gpdev-Pilcothink·Created 11 months ago·Updated 3 months ago· 2
Merge Texts With Gap
    • STRING
    text1
    text2
    text3
    text4
    text5
    text6
    gap1

    MergeTextsWithGap is the least glamorous node in the pilcothink pack, and honestly it's one of the handiest. You get six multiline text fields and one knob, and it joins whatever you type into a single STRING - skipping the boxes you left empty. That's it. If you've ever hand-built a long prompt out of two or three CLIP encode nodes, this is the same idea without the CLIP.

    Why would you reach for it instead of just typing one big string? Because in ComfyUI, strings flow out of other nodes. Your workflow already computes a base prompt, a style block, a negative from a wildcard node. Instead of pasting them together by hand every run, wire all three into MergeTextsWithGap and let it do the joining. It's the "compose text from parts" node you end up wanting in every LLM-adjacent graph - and this pack is full of LLM nodes, so it ships one.

    How it works

    The mechanism is trivially simple: it filters out the fields whose content is blank, then joins what's left with newlines. The gap input is the number of newlines between each piece, from 0 to 10 with a default of 1. So gap = 2 gives you one empty line between blocks - exactly what a chat model likes to see between a "context" section and a "question" section.

    # conceptually: separator = "\n" * gap
    # join only the non-blank texts
    

    The inputs that matter

    • text1 through text6 - six independent multiline fields. Leave any of them blank and it's simply dropped from the output.
    • gap - an INT, 0–10, default 1. The number of newlines placed between each non-empty piece.

    The single output is a STRING, which wires into anything that accepts text: the user_prompt of the pack's SLM or Vision generator, an Ollama generator's prompt, or any CLIP text encoder in the graph.

    Install

    Part of the comfyui_pilcothink_VisionSLM pack, so you're installing the whole thing:

    cd ComfyUI/custom_nodes
    git clone https://github.com/gpdev-Pilcothink/comfyui_pilcothink_VisionSLM
    

    Restart ComfyUI after that. Easier: open ComfyUI Manager, search for comfyui_pilcothink_VisionSLM, and install from there. Heads up - this pack drags in a heavy requirements list (transformers, torch, faiss-cpu, sentence-transformers, opencv), so it's worth installing even for one text node only if you already want the LLM side.

    Gotchas

    Nothing deep here, but two things bite. First, the join only counts non-blank fields - if you want a literal empty line inside your composed text, use gap = 2 rather than relying on a blank field, because a blank field disappears. Second, this is a brand-new pack with basically zero community mileage, so treat it as you'd treat any fresh custom node: clone from the official repo, don't grab it from a random mirror. Custom nodes run arbitrary code with full user access - the ecosystem's worst-case scenario for that isn't hypothetical, and a tiny pack like this one has no reputation track record yet.

    CategoryPilcothink/Text

    Inputs (7)

    NameTypeDefaultDescription
    text1STRING
    text2STRING
    text3STRING
    text4STRING
    text5STRING
    text6STRING
    gapINT10–10

    Outputs (1)

    NameTypeDescription
    STRINGSTRING