Nodes/Amazon Bedrock nodes for ComfyUI/Prompt Template with Two Inputs
ComfyUI Node

Prompt Template with Two Inputs

The glue for mixed-prompt workflows

By aws-samples·Created 2 years ago·Updated about a year ago· 30
Prompt Template with Two Inputs
    • STRING
    prompt
    prompt2
    prompt_template

    The single-input Prompt Template is the pack's most useful utility, but some workflows have two things that vary. That's this node: same templating idea, one extra slot, so you can mix a subject and a style, or an LLM's output and your own words, into a single finished prompt.

    How it works

    It takes prompt, prompt2, and a prompt_template, and does a chain of literal string replacements. The template can hold {prompt} or [prompt] (filled with the first input) and {prompt2} or [prompt2] (filled with the second). Output is one combined STRING.

    The implementation is two sets of .replace() calls - no API, no model, no AWS account. Pure string work in the "utils" category.

    A concrete use: say prompt is a subject ("a vintage motorcycle in a field"), prompt2 is a style ("golden-hour film photography, grain"), and the template is:

    {prompt}, {prompt2}, shot on 35mm, high detail
    

    You get a composed prompt without editing three nodes every run - or you wire prompt from a Bedrock LLM node and prompt2 from your own fixed text, and let the template do the joining.

    The inputs that matter

    • prompt - first variable.
    • prompt2 - second variable.
    • prompt_template - the constant skeleton with your four possible placeholders.

    All three required. Note the placeholders are interchangeable: you can use {prompt} and [prompt2] in the same template; each form maps to its own variable.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/aws-samples/comfyui-llm-node-for-amazon-bedrock.git
    pip install -r comfyui-llm-node-for-amazon-bedrock/requirements.txt
    

    Restart ComfyUI (or ComfyUI Manager → "Amazon Bedrock"). Light deps: boto3, requests, retry.

    Gotchas

    • Exact, case-sensitive matching. {Prompt2} won't fill from prompt2.
    • Empty input deletes the placeholder. If prompt2 is wired but produces an empty string, {prompt2} gets replaced with nothing - often what you want, but check if a template suddenly collapses.
    • No escaping. Want a literal {prompt} in the output? Not happening; it always substitutes.
    • Order matters in source, not in practice. The code replaces prompt's placeholders first, then prompt2's - since the placeholders are distinct strings, the order only matters in the pathological case of one variable's value containing the other's placeholder.

    If you need just one variable, the plain Prompt Template node is the simpler sibling. If you've got two sources of variation in a workflow - LLM refinement plus your own framing is the classic one - this is the glue. It won't change your life, but it'll stop you retyping the same sentence across ten nodes.

    Categoryutils

    Inputs (3)

    NameTypeDefaultDescription
    promptSTRING
    prompt2STRING
    prompt_templateSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING