🤖 Custom Model Prompt Generator
Prompt generation without the Ollama daemon
- layers_info
- image
- enhanced_prompt
- raw_output
CustomModelPromptGenerator (🤖 Custom Model Prompt Generator) is the sibling of the Ollama node that skips Ollama entirely. Instead of talking to a local server, it loads a .gguf model directly in-process via llama-cpp-python and uses it to turn your editing request into an enhanced prompt. If you've already got a quantized Qwen or DeepSeek file lying around - or you want a specific model that Ollama doesn't serve well - this is the node for you.
Why you'd pick it over the Ollama path: one less service to babysit. Ollama is a daemon with its own model management and a habit of hogging memory. This node loads and unloads the model on demand, releases it when the workflow is done, and - assuming the GGUF fits in your RAM - you can run it on CPU with zero VRAM, which matters when your GPU is already busy doing the actual image editing.
How it works
Drop a .gguf file into ComfyUI/models/custom_prompt_models/ and the node scans that directory (it creates it for you if it's missing). It then loads the file with llama.cpp's Llama() - 4096-token context, all CPU threads, and GPU layers offloaded automatically if CUDA is available. It detects the model family from the filename and applies the matching chat template (Qwen's <|im_start|> format or DeepSeek's ### System: format), stuffs your request and any canvas layer data in, and generates the prompt. That chat-template detail is the thing that makes the output usable - a bare completion from a chat-tuned model is mush without it.
The node caches the loaded model so consecutive runs don't reload it, and it distinguishes cleanly between the chatty system output and the raw model text.
Inputs and outputs that matter
editing_request- your edit description in plain words.model_file/model_name- picked from dropdowns populated by scanningmodels/custom_prompt_models/. Until you add a file, both show Chinese placeholders ("please add a model file"). Add the model first, then look at the node.max_tokens(64–2048, default 512),temperature(0.1–2, default 0.7),top_p(default 0.9) - the usual generation knobs.layers_infoandimage(optional) - plug in Super Canvas output and the model gets your annotations as context.custom_system_prompt(optional) - override the built-in "you are a professional image editing prompt generator" system prompt.
Outputs: enhanced_prompt (the cleaned instruction you actually want) and raw_output (the model's full completion, handy when it goes off the rails and you need to see why).
Installing it
Install the pack (ComfyUI Manager → "Kontext Super Prompt", or git clone https://github.com/aiaiaikkk/super-prompt-canvas), then the one dependency Manager will not install for you:
pip install llama-cpp-python
llama-cpp-python isn't in the pack's requirements.txt, so the node loads with a graceful "not installed" error until you add it. Then drop a GGUF into ComfyUI/models/custom_prompt_models/ and restart.
Where people get burned
Missing llama-cpp-python is the number one failure - the node raises a clear message telling you to run the pip command, so at least it's diagnosable. On Windows, the prebuilt wheels don't ship CUDA acceleration; if you want GPU offload you'll have to compile with CMAKE_ARGS="-DGGML_CUDA=on" or accept CPU-only. And if you're new to GGUFs, the quality ladder is worth remembering: Q8 is essentially indistinguishable from the fp16 original at half the size, Q4_K_M is the pragmatic floor for big models. A Q2 quant of a small model will produce instructions that read like a lost AI. Start with a Q4 or better.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| editing_request | STRING | 请描述你想要的图像编辑效果 | — |
| model_name | COMBO | 请先添加模型文件 | 1 options: 请先添加模型文件 |
| model_file | COMBO | 请将.gguf模型文件放入models/custom_prompt_models目录 | 1 options: 请将.gguf模型文件放入models/custom_prompt_models目录 |
| max_tokens | INT | 51264–2048 | — |
| temperature | FLOAT | 0.70.1–2 | — |
| top_p | FLOAT | 0.900.1–1 | — |
| layers_infoopt | LAYERS_INFO | — | |
| imageopt | IMAGE | — | |
| custom_system_promptopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| enhanced_prompt | STRING | — |
| raw_output | STRING | — |