Nodes/Sage Utils/Construct LLM Prompt
ComfyUI Node

Construct LLM Prompt

Turn your image-generation ask into a prompt an LLM will actually obey

By arcum42·Created 2 years ago·Updated 28 days ago· 33
Construct LLM Prompt
    • prompt
    prompt
    extra_instructions
    adult_contentfalse
    avoid_euphemismsfalse
    avoid_flowery_languagefalse
    be_specificfalse
    erotic_imageryfalse
    exaggerate_qualityfalse
    exclude_sexualfalse
    exclude_watermarksfalse
    non_technicalfalse
    only_describe_key_elementsfalse
    only_output_descriptiontrue
    use_vulgar_languagefalse

    The pack's LLM integration is the ambitious half of Sage Utils - a whole chat tab, vision support, and a stack of prompt-building nodes, all pointed at local models running in LM Studio or Ollama. Construct LLM Prompt is the node that builds the text you'd feed such a model: it assembles a structured instruction prompt from a base template plus a row of toggleable constraints, and hands you the finished STRING.

    Here's what you get on the inputs. The prompt combo is the base template, and it's a dropdown of curated starting points from the pack's llm_prompts.json config: things like tagging/booru, tagging/danbooru, art_critique/art_critic, description, caption, and more. Pick the job you want the LLM to do. extra_instructions is your free-text addition - whatever specific guidance you want appended verbatim. Then comes the row of booleans that spice the base template: only_output_description (on by default), be_specific, avoid_flowery_language, non_technical, exaggerate_quality, exclude_watermarks, adult_content, erotic_imagery, exclude_sexual, use_vulgar_language... you get the idea. Each one appends a pre-written instruction line to the prompt when toggled on.

    Mechanically it's text assembly, not magic. The node picks the selected base prompt, guarantees it ends with proper punctuation, appends each enabled toggle's canned instruction line, then tacks on your extra_instructions. The output is a single prompt string ready to feed the LLM tab, an LLM node, or anything else that speaks to a model. It's opinionated and that's the point: by construction, you get a well-formed instruction instead of the vague one-liner people usually type into a chat box.

    Now the honest framing, because you'll hit it fast: the LLM features are the part of Sage Utils the README itself flags as work in progress, and they lean on you having a local model server running. The pack tries to reach LM Studio/Ollama at startup and will log connection warnings when neither is up - harmless noise, but real. Set SAGEUTILS_LOG_LEVEL=WARNING to quiet it. The prompt-construction nodes themselves work fine without a server, though: they're just string building. So you can happily use this node to generate a prompt, copy it, and paste it anywhere - including into an online model, if you're not running one locally.

    The sibling node, Construct LLM Prompt Extra, is the same idea for the "detail" instructions (describe mood, include lighting, camera details, materials, and so on). Run this one for the main instruction, that one for the detail layer, and join them if you want both.

    Install

    ComfyUI Manager → search Sage Utils → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/arcum42/ComfyUI_SageUtils.git
    cd ComfyUI_SageUtils && pip install -r requirements.txt
    

    Restart ComfyUI. For the LLM tab to do anything you'll also need LM Studio (load a model, start its local server) or Ollama (ollama pull llama3.2). The node itself has no extra requirements beyond the pack's dynamicprompts dependency.

    CategorySage Utils/LLM

    Inputs (14)

    NameTypeDefaultDescription
    promptCOMBOThe base prompt template to construct.
    extra_instructionsSTRINGAdditional instructions to append to the generated prompt.
    adult_contentBOOLEANfalseAdult Content
    avoid_euphemismsBOOLEANfalseAvoid Euphemisms
    avoid_flowery_languageBOOLEANfalseAvoid Flowery Language
    be_specificBOOLEANfalseBe Specific
    erotic_imageryBOOLEANfalseErotic Imagery
    exaggerate_qualityBOOLEANfalseExaggerate Image Quality
    exclude_sexualBOOLEANfalseExclude Sexual Content
    exclude_watermarksBOOLEANfalseExclude Watermarks
    non_technicalBOOLEANfalseNon-technical Terms
    only_describe_key_elementsBOOLEANfalseDescribe Key Elements Only
    only_output_descriptionBOOLEANtrueOnly Output Description
    use_vulgar_languageBOOLEANfalseUse Vulgar Slang and Profanity

    Outputs (1)

    NameTypeDescription
    promptSTRINGThe constructed LLM prompt.