Nodes/neonllama/🧠 Ollama & LM Studio Prompt From Idea
ComfyUI Node

🧠 Ollama & LM Studio Prompt From Idea

A local LLM does your prompt-writing, no API key

By NeonLightning·Created about a year ago·Updated about a year ago· 2
🧠 Ollama & LM Studio Prompt From Idea
    • prompt
    • negative
    • idea
    model
    ideafuturistic cyberpunk city
    negative
    max_tokens75
    min_tokens50
    max_attempts30
    regen_on_each_usetrue
    just_use_ideafalse
    exclude_commafalse
    randomize_seedtrue
    llm_seed207824427
    randomize_temptrue
    llm_temp0.59
    keepllmfalse

    The "LLM prompt enhancer" is a well-worn ComfyUI niche: you're sick of hand-writing comma soup, so you let a local language model expand a bare idea into a dense, image-model-ready prompt. OllamaPromptFromIdea is one of those, from the tiny neonllama pack. You type haunted subway station with broken lights, and a model running through Ollama or LM Studio turns it into dark abandoned subway, flickering fluorescent lights, cracked tiled walls, shadowy corners….

    Two things to know before you care. First, the name is a half-lie: despite the "Ollama" in the class name, it talks to LM Studio just as happily. Second, and more importantly, it calls no cloud API and needs no key - everything runs against a model you already run locally. That's the whole appeal of this category, and this node keeps the plumbing (HTTP calls, model dropdown, token counting) out of your workflow.

    How it actually works

    At startup the node pings Ollama's /api/tags endpoint and the LM Studio SDK, then fills the model dropdown with ollama:<name> and lmstudio:<name> entries. Each line of your idea box becomes a separate generation task. The system prompt is aggressive: short visual fragments, comma-separated, sorted by visual importance, no emotions, no storytelling, and the reply must land between min_tokens and max_tokens.

    If the output is out of bounds, it doesn't just give up - it re-prompts the model to trim or expand, randomizing temperature each attempt until something fits (up to max_attempts, default 30). Multiple idea lines each get their own prompt, joined with BREAK. It writes everything to llm_generated_prompt_log.txt in your ComfyUI folder, and if you turn regen_on_each_use off it'll serve that cached file instead of re-running.

    Inputs and outputs that matter

    • model - your local LLM, picked from the dropdown. Needs Ollama or LM Studio running when ComfyUI starts.
    • idea - the concept(s), one per line. The tooltip says max 3 lines, ~231 tokens.
    • negative - words to avoid. It's returned verbatim as your negative prompt, and the code also feeds it to the LLM as a "do not use" clause, despite the tooltip claiming it's SD-only.
    • min_tokens / max_tokens - the size window for each generated prompt (defaults 50/75).
    • just_use_idea - bypasses the LLM entirely and passes your idea straight through. Handy for testing wiring.
    • keepllm - keep the model resident; by default it unloads after each generation.

    Outputs are three strings: prompt (wire into your CLIP Text Encode positive), negative (the negative encoder), and idea (a pass-through for debugging).

    Installing it

    Via ComfyUI Manager, search "NeonLlama". Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/NeonLightning/neonllama
    # restart ComfyUI
    

    The pack's requirements.txt lists only tokenizers and lmstudio - and both already ship with ComfyUI or are needed only for the LM Studio path. The real requirement is a running backend and a small model:

    ollama pull qwen3:4b   # or llama3.2, whatever you have
    

    Note the dropdown is populated once when ComfyUI loads. If Ollama isn't running yet, you get "No models available - check Ollama/LM Studio" and need to restart ComfyUI. First run also downloads a CLIP tokenizer from HuggingFace.

    Where it bites

    The honest caveat: the version on main (the repo's only commit, as of this writing) calls two helper functions - estimate_tokens() and clear_ollama_model() - that are never defined in the file. So after the first successful model reply, generation crashes with a NameError traceback in the console. The README's "accurate token estimation, adaptive temperature" machinery can't actually run in this snapshot. If you see [LLM Error] name 'estimate_tokens' is not defined, that's the node, not you - check the repo, it may be fixed by now.

    One more: this is tuned for SDXL-style tag prompting, and the BREAK separator only means something on the SD1.5/SDXL CLIP lineage. Feed the output to a newer LLM-encoded checkpoint and BREAK is just ignored text. Great for Illustrious/Pony workflows; wasted on those.

    CategoryLLM Prompts

    Inputs (14)

    NameTypeDefaultDescription
    modelCOMBOSelect the LLM model (Ollama or LM Studio) to generate prompts with.
    ideaSTRINGfuturistic cyberpunk cityEnter the core concept or theme for your prompt. You can have separated ideas if you have a hard return. Only use up to 3 lines though, to a maximum of 231 tokens.
    negativeSTRINGWords or themes to exclude from the prompt (used by Stable Diffusion, not LLM).
    max_tokensINT7510–1024Maximum token length for the generated prompt.
    min_tokensINT5010–1024Minimum token length for the generated prompt.
    max_attemptsINT301–200Number of attempts to generate a prompt fitting token limits.
    regen_on_each_useBOOLEANtrueForce regeneration on each node execution (doesn't matter if just_use_idea is on).
    just_use_ideaBOOLEANfalseSkip Generating and just use idea as prompt.
    exclude_commaBOOLEANfalseDisables commas and sentence removal suggesting.
    randomize_seedBOOLEANtrueUse a random seed on each generation.
    llm_seedINT2078244270–999999999Fixed seed (only used if randomize_seed is off).
    randomize_tempBOOLEANtrueUse a random temperature on each generation.
    llm_tempFLOAT0.590.1–1Fixed temperature (only used if randomize_temp is off).
    keepllmBOOLEANfalseKeep LLM model in memory.

    Outputs (3)

    NameTypeDescription
    promptSTRING
    negativeSTRING
    ideaSTRING