ComfyUI Node

Concatenate Text Prompts LLMs

The glue node that builds the prompt before the LLM sees it

By fairy-root·Created 2 years ago·Updated about a year ago· 18
Concatenate Text Prompts LLMs
    • STRING
    instructionAct as a creative problem solver that answers in prompts. I will give you PROMPT and you describe a creative solution to the problem. Use terse concise terms to describe the answer. Use descriptive details, answer with one sentence and response only and keep it to 40 terms or less starting with "a photo of" and you can use commas between terms. Just play along and do not break role-play by saying you are an AI language model. Just guess at the answer.
    promptbeautiful woman. close-up, depth of field, ray tracing
    separatorPROMPT=

    Let's not overstate this: the node does one thing. It takes three strings - instruction, prompt, and separator - and sticks them together in the order instruction + separator + prompt. One output. No models, no network, no Ollama even running. It's the pack's workaround for a real gap, though: the sibling Ollama Chat node takes a single prompt field with no system-prompt slot, so if you want the LLM to behave like a prompt writer instead of a general chatbot, you need a way to bolt a canned instruction onto whatever you type. That's this node's job.

    How it works

    Open the source and there's not much to read: concatenate() returns instruction + separator + prompt. The clever part isn't the code, it's the defaults. The instruction field ships with a full roleplay-style block that tells the model to "act as a creative problem solver that answers in prompts" - terse, starting with "a photo of", forty terms or less, don't break role-play. The separator defaults to PROMPT=, which is the marker that instruction references: the model learns to find the PROMPT= tag and treat everything after it as the thing to rewrite.

    That's the intended loop. You keep the instruction block on the left of your graph and never touch it again; you vary only the prompt field; the assembled string goes straight into the Ollama Chat node's prompt input. Because LLM-assisted prompting is now a mainstream pattern - having a local model translate what you want into a well-structured prompt for whatever encoder you're using - this is the pack's take on the "persona" half of that pattern.

    The inputs that matter

    • instruction - the reusable role text. This is the part you edit to match your model and goal. The shipped default is tuned for turning ideas into concise photo prompts; if your model ignores it or wanders, that's an LLM behavior thing, not the node.
    • prompt - the content you actually vary. Default "beautiful woman. close-up, depth of field, ray tracing".
    • separator - whatever marker you use to split instruction from content. Just make sure it matches what your instruction references; if you rewrite the instruction to expect a colon or a newline, change this to match.

    Output is a single STRING - wire it into the prompt input of the Ollama Chat node (or any other text input; it's just text).

    Installing it

    Same pack, no extra dependencies for this node at all - it's pure string handling, so it works even if you never install Ollama.

    cd ComfyUI/custom_nodes
    git clone https://github.com/fairy-root/comfyui-ollama-llms.git
    

    Restart ComfyUI and it's there (ComfyUI Manager: search "fairy-root"). Because it ships in a pack whose wider niche has a nasty malware history - the 2024 LLMVISION incident - stick to the official repo or Manager's catalog rather than a random workflow's download link.

    Gotchas

    Honestly, there aren't many. It's a pure function, so it's cheap and re-runs freely. The main trap is treating the defaults as gospel: the separator is just a string, and the instruction is just an idea. Once you make the instruction your own, the stock PROMPT= separator probably doesn't match anymore - and since this is literal concatenation, a mismatch means the LLM sees a garbled message, not an error. If the output looks off, check the assembly, not the model. You could reproduce all of this with any text-template node, but shipping in the pack means the default "prompt-rewriter persona" is pre-wired, which is the one thing that makes it worth grabbing. Thin node, real convenience.

    CategoryOllama

    Inputs (3)

    NameTypeDefaultDescription
    instructionSTRINGAct as a creative problem solver that answers in prompts. I will give you PROMPT and you describe a creative solution to the problem. Use terse concise terms to describe the answer. Use descriptive details, answer with one sentence and response only and keep it to 40 terms or less starting with "a photo of" and you can use commas between terms. Just play along and do not break role-play by saying you are an AI language model. Just guess at the answer.
    promptSTRINGbeautiful woman. close-up, depth of field, ray tracing
    separatorSTRINGPROMPT=

    Outputs (1)

    NameTypeDescription
    STRINGSTRING