diff --git a/README.md b/README.md
index 44494cd..d206137 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ A complete prompt management solution featuring three core capabilities:
**Prompt Extractor** — Extract prompts, LoRA configurations, and checkpoint/model paths from existing images, videos, or JSON workflow files. Will extract first frame from any video. Automatically parses embedded metadata and outputs active LoRA as Lora stacks, plus resolved model paths (High/Low for dual-model workflows like Wan). Supports ComfyUI, A1111/Forge, and WebP metadata formats. When used in conjunction with Prompt Manager Advanced, Loras will be automatically found if available, regardless of path. For those that aren't, right click offers the option to look for them on Civitai. Browse files from both your input and output folders.
-**Prompt Model Loader** — Load checkpoints or diffusion models from a string path output by Prompt Extractor. Auto-detects whether the model is a checkpoint (outputs MODEL + CLIP + VAE) or a diffusion/UNET model (outputs MODEL only). Works around ComfyUI's combo type limitation, allowing extracted model paths to connect directly to a loader.
+**Prompt Model Loader** — Load checkpoints, diffusion, or GGUF models from a string path output by Prompt Extractor. Auto-detects whether the model is a checkpoint (outputs MODEL + CLIP + VAE) or a diffusion/UNET/GGUF model (outputs MODEL only). Displays model type badge and name directly on the node. Works around ComfyUI's combo type limitation, allowing extracted model paths to connect directly to a loader. Supports [ComfyUI-GGUF](https://github.com/city96/ComfyUI-GGUF) models when the extension is installed.
___
@@ -73,8 +73,12 @@ ___
### Prompt Model Loader:
- **String-to-Model Loading**: Takes a model path string (from Prompt Extractor) and loads the model directly
-- **Auto-Detection**: Automatically detects whether the path is a checkpoint (returns MODEL + CLIP + VAE) or diffusion/UNET model (returns MODEL only)
-- **Model Path Resolution**: Works with both full paths and relative paths, searching checkpoints and diffusion_models folders
+- **Auto-Detection**: Automatically detects whether the path is a checkpoint (returns MODEL + CLIP + VAE) or diffusion/UNET/GGUF model (returns MODEL only)
+- **GGUF Support**: Loads GGUF models when [ComfyUI-GGUF](https://github.com/city96/ComfyUI-GGUF) is installed, with automatic runtime detection
+- **Visual Model Info**: Displays model type badge (Checkpoint/Diffusion/GGUF) and model name directly on the node
+- **State Persistence**: Model info display and output slot visibility persist across tab switches and workflow reloads
+- **Graceful Error Handling**: Displays a red "NOT FOUND" badge instead of crashing when a model path cannot be resolved
+- **Model Path Resolution**: Works with both full paths and relative paths, searching checkpoints, diffusion_models, and unet folders
- **Weight Dtype Support**: Optional weight dtype selection for memory optimization
### Prompt Generator
@@ -254,6 +258,15 @@ Preference settings can be found in ComfyUI Settings → Prompt Manager
## Changelog
+### version 1.22.1
+- **Prompt Model Loader Improvements**
+ - Added GGUF model support via runtime detection of [ComfyUI-GGUF](https://github.com/city96/ComfyUI-GGUF) extension
+ - Visual model type badge (Checkpoint/Diffusion/GGUF/NOT FOUND) and model name displayed on the node
+ - CLIP and VAE output slots automatically hidden for non-checkpoint models
+ - State persistence: model info and output slot visibility survive tab switches and workflow reloads
+ - Graceful error handling: shows red "NOT FOUND" badge instead of crashing on missing models
+ - Searches `unet_gguf` folder paths registered by ComfyUI-GGUF
+
### version 1.22.0
- **New Node: Prompt Model Loader**
- Loads checkpoints or diffusion/UNET models from a string path (output by Prompt Extractor)
diff --git a/__init__.py b/__init__.py
index 9de8732..1a367d7 100644
--- a/__init__.py
+++ b/__init__.py
@@ -2,7 +2,7 @@
ComfyUI Prompt Manager - A simple custom node for saving and reusing prompts
A prompt management system for ComfyUI with LLM input support
"""
-__version__ = "1.22.0"
+__version__ = "1.22.1"
__author__ = "François Beaudry"
__license__ = "MIT"
diff --git a/js/prompt_model_loader.js b/js/prompt_model_loader.js
new file mode 100644
index 0000000..6437be9
--- /dev/null
+++ b/js/prompt_model_loader.js
@@ -0,0 +1,181 @@
+/**
+ * PromptModelLoader Extension for ComfyUI
+ * Displays model type and name info on the node, hides CLIP/VAE slots for non-checkpoint models.
+ */
+
+import { app } from "../../scripts/app.js";
+
+app.registerExtension({
+ name: "PromptManager.ModelLoader",
+
+ async beforeRegisterNodeDef(nodeType, nodeData) {
+ if (nodeData.name !== "PromptModelLoader") return;
+
+ // Hook into onExecuted to receive UI data from Python
+ const origOnExecuted = nodeType.prototype.onExecuted;
+ nodeType.prototype.onExecuted = function (message) {
+ origOnExecuted?.apply(this, arguments);
+
+ const info = message?.model_info?.[0];
+ if (!info) return;
+
+ this._applyModelInfo(info.model_type || "Unknown", info.model_name || "");
+ };
+
+ // Central method to apply model info (used by both onExecuted and onConfigure)
+ nodeType.prototype._applyModelInfo = function (modelType, modelName) {
+ const isCheckpoint = modelType === "Checkpoint";
+
+ // Store for display and serialization
+ this._modelType = modelType;
+ this._modelName = modelName;
+
+ // Update title
+ this.title = `Prompt Model Loader [${modelType}]`;
+
+ // Show/hide CLIP and VAE outputs
+ this._updateOutputSlots(isCheckpoint);
+
+ // Create info widget
+ this._ensureInfoWidget();
+ this.setDirtyCanvas(true, true);
+ };
+
+ // Save state into the workflow JSON
+ const origOnSerialize = nodeType.prototype.onSerialize;
+ nodeType.prototype.onSerialize = function (o) {
+ origOnSerialize?.apply(this, arguments);
+ if (this._modelType && this._modelName) {
+ o._modelLoaderState = {
+ modelType: this._modelType,
+ modelName: this._modelName
+ };
+ }
+ };
+
+ // Restore state when workflow is loaded / tab is switched back
+ const origOnConfigure = nodeType.prototype.onConfigure;
+ nodeType.prototype.onConfigure = function (info) {
+ origOnConfigure?.apply(this, arguments);
+ const state = info?._modelLoaderState;
+ if (state && state.modelType && state.modelName) {
+ // Defer to next frame so the node is fully set up
+ requestAnimationFrame(() => {
+ this._applyModelInfo(state.modelType, state.modelName);
+ });
+ }
+ };
+
+ // Manage output slot visibility
+ nodeType.prototype._updateOutputSlots = function (isCheckpoint) {
+ if (!this._originalOutputs) {
+ // Save original outputs on first run
+ this._originalOutputs = this.outputs.map(o => ({ ...o }));
+ }
+
+ if (isCheckpoint) {
+ // Restore all 3 outputs
+ while (this.outputs.length < 3) {
+ const orig = this._originalOutputs[this.outputs.length];
+ this.addOutput(orig.name, orig.type);
+ }
+ } else {
+ // Remove CLIP (index 1) and VAE (index 2) if present
+ // Disconnect them first to avoid dangling links
+ for (let i = this.outputs.length - 1; i >= 1; i--) {
+ if (this.outputs[i].links && this.outputs[i].links.length > 0) {
+ for (const linkId of [...this.outputs[i].links]) {
+ this.disconnectOutput(i);
+ }
+ }
+ this.removeOutput(i);
+ }
+ }
+ this.computeSize();
+ };
+
+ // Info widget helper
+ nodeType.prototype._ensureInfoWidget = function () {
+ let widget = this.widgets?.find(w => w.name === "_model_info_display");
+ if (!widget) {
+ widget = {
+ name: "_model_info_display",
+ type: "custom",
+ y: 0,
+ computeSize: () => [0, 44],
+ draw: function (ctx, node, widgetWidth, y) {
+ if (!node._modelName) return;
+
+ const padding = 8;
+
+ // Type badge colors
+ const typeColors = {
+ "Checkpoint": "#4CAF50",
+ "Diffusion": "#2196F3",
+ "GGUF": "#FF9800",
+ "NOT FOUND": "#F44336",
+ "Unknown": "#9E9E9E"
+ };
+ const typeText = node._modelType || "Unknown";
+ const badgeColor = typeColors[typeText] || typeColors["Unknown"];
+
+ // Badge pill
+ ctx.font = "bold 11px Arial";
+ const typeWidth = ctx.measureText(typeText).width + 14;
+ ctx.fillStyle = badgeColor;
+ ctx.beginPath();
+ ctx.roundRect(padding, y + 4, typeWidth, 16, 8);
+ ctx.fill();
+
+ // Badge text
+ ctx.fillStyle = "#FFFFFF";
+ ctx.textAlign = "left";
+ ctx.textBaseline = "middle";
+ ctx.fillText(typeText, padding + 7, y + 12);
+
+ // Model name below badge
+ ctx.font = "12px Arial";
+ ctx.fillStyle = "#CCCCCC";
+ const maxNameWidth = widgetWidth - padding * 2;
+ let displayName = node._modelName;
+ while (ctx.measureText(displayName).width > maxNameWidth && displayName.length > 5) {
+ displayName = displayName.slice(0, -4) + "...";
+ }
+ ctx.fillText(displayName, padding, y + 34);
+ }
+ };
+ if (!this.widgets) this.widgets = [];
+ this.widgets.push(widget);
+ this.computeSize();
+ }
+ };
+
+ // Reset display on clear/reconnect
+ const origOnConnectionsChange = nodeType.prototype.onConnectionsChange;
+ nodeType.prototype.onConnectionsChange = function () {
+ origOnConnectionsChange?.apply(this, arguments);
+ // Reset info when input connection changes
+ if (arguments[1] === 0 && arguments[0] === 1) {
+ this._modelType = null;
+ this._modelName = null;
+ this.title = "Prompt Model Loader";
+ // Restore all outputs
+ if (this._originalOutputs) {
+ while (this.outputs.length < 3) {
+ const orig = this._originalOutputs[this.outputs.length];
+ this.addOutput(orig.name, orig.type);
+ }
+ }
+ // Remove info widget
+ if (this.widgets) {
+ const idx = this.widgets.findIndex(w => w.name === "_model_info_display");
+ if (idx >= 0) {
+ this.widgets.splice(idx, 1);
+ this.computeSize();
+ }
+ }
+ this.setDirtyCanvas(true, true);
+ }
+ };
+ }
+});
diff --git a/nodes/prompt_extractor.py b/nodes/prompt_extractor.py
index 427015e..783c353 100644
--- a/nodes/prompt_extractor.py
+++ b/nodes/prompt_extractor.py
@@ -301,11 +301,15 @@ def strip_model_extension(name):
def get_available_models():
- """Get all available models from ComfyUI's checkpoints and diffusion_models folders."""
+ """Get all available models from ComfyUI's checkpoints, diffusion_models and unet folders."""
models = []
- for folder_name in ['checkpoints', 'diffusion_models']:
+ seen = set()
+ for folder_name in ['checkpoints', 'diffusion_models', 'unet', 'unet_gguf']:
try:
- models.extend(folder_paths.get_filename_list(folder_name))
+ for m in folder_paths.get_filename_list(folder_name):
+ if m not in seen:
+ seen.add(m)
+ models.append(m)
except Exception:
pass
return models
@@ -2466,16 +2470,17 @@ def parse_workflow_for_prompts(prompt_data, workflow_data=None):
# Check all available context for high/low indicators
all_context = f"{inp_label} {inp_name_lower} {terminal_title} {loader_title} {model_name_lower}"
+ all_context_compact = all_context.replace('_', '').replace('-', '').replace(' ', '')
has_high = bool(
re.search(r'\bhigh\b', all_context) or
- 'highnoise' in all_context.replace('_', '').replace('-', '').replace(' ', '') or
- 'high_noise' in all_context
+ re.search(r'high(?:noise|_noise)', all_context_compact) or
+ re.search(r'i2v\s*high|t2v\s*high|_high|high_', all_context)
)
has_low = bool(
re.search(r'\blow\b', all_context) or
- 'lownoise' in all_context.replace('_', '').replace('-', '').replace(' ', '') or
- 'low_noise' in all_context
+ re.search(r'low(?:noise|_noise)', all_context_compact) or
+ re.search(r'i2v\s*low|t2v\s*low|_low|low_', all_context)
)
if has_low and not has_high:
@@ -2523,8 +2528,14 @@ def parse_workflow_for_prompts(prompt_data, workflow_data=None):
model_names_seen.add(model_name)
model_name_lower = model_name.lower()
- has_low = bool('low_noise' in model_name_lower or '_low' in model_name_lower)
- has_high = bool('high_noise' in model_name_lower or '_high' in model_name_lower)
+ has_low = bool(
+ 'low_noise' in model_name_lower or '_low' in model_name_lower or
+ re.search(r'i2v\s*low|t2v\s*low|low_', model_name_lower)
+ )
+ has_high = bool(
+ 'high_noise' in model_name_lower or '_high' in model_name_lower or
+ re.search(r'i2v\s*high|t2v\s*high|high_', model_name_lower)
+ )
if has_low and not has_high:
print(f"[PromptExtractor] Model → B (low, API fallback): {model_name}")
diff --git a/nodes/prompt_model_loader.py b/nodes/prompt_model_loader.py
index 36eb90e..b53b5ed 100644
--- a/nodes/prompt_model_loader.py
+++ b/nodes/prompt_model_loader.py
@@ -1,13 +1,69 @@
"""
-ComfyUI Model Loader - Load checkpoint or diffusion model from a path string.
+ComfyUI Model Loader - Load checkpoint, diffusion, UNET, or GGUF model from a path string.
Automatically determines the model type based on available folders.
+Supports GGUF models when ComfyUI-GGUF custom node is installed.
"""
import os
+import logging
import folder_paths
import comfy.sd
import torch
+def _get_gguf_module():
+ """Get the ComfyUI-GGUF module if the node is loaded, None otherwise."""
+ try:
+ import nodes as comfy_nodes
+ gguf_cls = comfy_nodes.NODE_CLASS_MAPPINGS.get("UnetLoaderGGUF")
+ if gguf_cls is None:
+ return None
+ # Get the module the class came from
+ import sys
+ mod = sys.modules.get(gguf_cls.__module__)
+ if mod is None:
+ return None
+ # The ops/loader are siblings in the same package
+ package = gguf_cls.__module__.rsplit('.', 1)[0]
+ ops_mod = sys.modules.get(f"{package}.ops")
+ loader_mod = sys.modules.get(f"{package}.loader")
+ if ops_mod and loader_mod:
+ return {
+ "GGMLOps": ops_mod.GGMLOps,
+ "gguf_sd_loader": loader_mod.gguf_sd_loader,
+ "GGUFModelPatcher": mod.GGUFModelPatcher,
+ }
+ return None
+ except Exception:
+ return None
+
+
+def _load_gguf_unet(unet_path):
+ """Load a GGUF model using ComfyUI-GGUF's loader. Returns MODEL."""
+ import inspect
+
+ gguf = _get_gguf_module()
+ if gguf is None:
+ raise RuntimeError("[ModelLoader] ComfyUI-GGUF module not available")
+
+ ops = gguf["GGMLOps"]()
+ sd, extra = gguf["gguf_sd_loader"](unet_path)
+
+ kwargs = {}
+ valid_params = inspect.signature(comfy.sd.load_diffusion_model_state_dict).parameters
+ if "metadata" in valid_params:
+ kwargs["metadata"] = extra.get("metadata", {})
+
+ model = comfy.sd.load_diffusion_model_state_dict(
+ sd, model_options={"custom_operations": ops}, **kwargs,
+ )
+ if model is None:
+ raise RuntimeError(f"[ModelLoader] Could not detect model type of GGUF: {unet_path}")
+
+ model = gguf["GGUFModelPatcher"].clone(model)
+ model.patch_on_device = False
+ return model
+
+
class PromptModelLoader:
"""
Load a checkpoint or diffusion model from a model name/path string.
@@ -40,14 +96,60 @@ class PromptModelLoader:
RETURN_NAMES = ("model", "clip", "vae")
FUNCTION = "load_model"
CATEGORY = "Prompt Manager"
- DESCRIPTION = "Load a checkpoint or diffusion model from a path string. Auto-detects model type. CLIP and VAE are None for diffusion models."
+ OUTPUT_NODE = True
+ DESCRIPTION = "Load a checkpoint, diffusion, UNET, or GGUF model from a path string. Auto-detects model type. Supports GGUF when ComfyUI-GGUF is installed. CLIP and VAE are None for non-checkpoint models."
+
+ def _build_model_options(self, weight_dtype):
+ """Build model_options dict from weight_dtype selection."""
+ model_options = {}
+ if weight_dtype == "fp8_e4m3fn":
+ model_options["dtype"] = torch.float8_e4m3fn
+ elif weight_dtype == "fp8_e4m3fn_fast":
+ model_options["dtype"] = torch.float8_e4m3fn
+ model_options["fp8_optimizations"] = True
+ elif weight_dtype == "fp8_e5m2":
+ model_options["dtype"] = torch.float8_e5m2
+ return model_options
def load_model(self, model_path, weight_dtype="default"):
model_path = model_path.strip()
if not model_path:
- raise ValueError("[ModelLoader] No model path provided")
+ return {
+ "ui": {"model_info": [{"model_type": "NOT FOUND", "model_name": "(no model path provided)"}]},
+ "result": (None, None, None)
+ }
- # Try checkpoint first, then diffusion_models
+ # Extract display name (basename without directory)
+ display_name = os.path.basename(model_path.replace('\\', '/'))
+ is_gguf = model_path.lower().endswith('.gguf')
+
+ def _result(model_type, model, clip, vae):
+ return {
+ "ui": {"model_info": [{"model_type": model_type, "model_name": display_name}]},
+ "result": (model, clip, vae)
+ }
+
+ # GGUF models — use ComfyUI-GGUF if active
+ if is_gguf:
+ if _get_gguf_module() is None:
+ print(f"[ModelLoader] GGUF model detected but ComfyUI-GGUF is not installed: {model_path}")
+ return _result("NOT FOUND", None, None, None)
+
+ # Search unet_gguf (registered by ComfyUI-GGUF), unet, and diffusion_models folders
+ for folder_name in ['unet_gguf', 'unet', 'diffusion_models']:
+ try:
+ full_path = folder_paths.get_full_path(folder_name, model_path)
+ if full_path and os.path.isfile(full_path):
+ print(f"[ModelLoader] Loading GGUF model via ComfyUI-GGUF: {model_path} (from {folder_name})")
+ model = _load_gguf_unet(full_path)
+ return _result("GGUF", model, None, None)
+ except Exception:
+ continue
+
+ print(f"[ModelLoader] GGUF model not found: '{model_path}' — searched unet_gguf, unet, diffusion_models")
+ return _result("NOT FOUND", None, None, None)
+
+ # Try checkpoint first
ckpt_path = folder_paths.get_full_path("checkpoints", model_path)
if ckpt_path and os.path.isfile(ckpt_path):
print(f"[ModelLoader] Loading checkpoint: {model_path}")
@@ -57,41 +159,16 @@ class PromptModelLoader:
output_clip=True,
embedding_directory=folder_paths.get_folder_paths("embeddings"),
)
- return out[:3]
+ return _result("Checkpoint", out[0], out[1], out[2])
- # Try diffusion_models
- diff_path = folder_paths.get_full_path("diffusion_models", model_path)
- if diff_path and os.path.isfile(diff_path):
- print(f"[ModelLoader] Loading diffusion model: {model_path}")
- model_options = {}
- if weight_dtype == "fp8_e4m3fn":
- model_options["dtype"] = torch.float8_e4m3fn
- elif weight_dtype == "fp8_e4m3fn_fast":
- model_options["dtype"] = torch.float8_e4m3fn
- model_options["fp8_optimizations"] = True
- elif weight_dtype == "fp8_e5m2":
- model_options["dtype"] = torch.float8_e5m2
+ # Try diffusion_models and unet folders
+ model_options = self._build_model_options(weight_dtype)
+ for folder_name in ['diffusion_models', 'unet']:
+ full_path = folder_paths.get_full_path(folder_name, model_path)
+ if full_path and os.path.isfile(full_path):
+ print(f"[ModelLoader] Loading diffusion/UNET model: {model_path} (from {folder_name})")
+ model = comfy.sd.load_diffusion_model(full_path, model_options=model_options)
+ return _result("Diffusion", model, None, None)
- model = comfy.sd.load_diffusion_model(diff_path, model_options=model_options)
- return (model, None, None)
-
- # Try unet (some setups use this folder)
- unet_path = folder_paths.get_full_path("unet", model_path)
- if unet_path and os.path.isfile(unet_path):
- print(f"[ModelLoader] Loading UNET model: {model_path}")
- model_options = {}
- if weight_dtype == "fp8_e4m3fn":
- model_options["dtype"] = torch.float8_e4m3fn
- elif weight_dtype == "fp8_e4m3fn_fast":
- model_options["dtype"] = torch.float8_e4m3fn
- model_options["fp8_optimizations"] = True
- elif weight_dtype == "fp8_e5m2":
- model_options["dtype"] = torch.float8_e5m2
-
- model = comfy.sd.load_diffusion_model(unet_path, model_options=model_options)
- return (model, None, None)
-
- raise FileNotFoundError(
- f"[ModelLoader] Model not found: '{model_path}'. \n"
- f"Searched in checkpoints and diffusion_models folders."
- )
+ print(f"[ModelLoader] Model not found: '{model_path}' — searched checkpoints, diffusion_models, unet")
+ return _result("NOT FOUND", None, None, None)
diff --git a/pyproject.toml b/pyproject.toml
index 2c8fe23..fc94577 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,7 +1,7 @@
[project]
name = "prompt-manager"
description = "A comprehensive prompt management system for ComfyUI that saves complete workflow recipes including prompts, LoRAs, and their settings. Features AI-powered prompt generation, prompt extraction from ComfyUI/A1111 images and videos, and Dual LoRA Stack support for Wan workflows."
-version = "1.22.0"
+version = "1.22.1"
license = {file = "LICENSE"}
# classifiers = [
# # For OS-independent nodes (works on all operating systems)
diff --git a/test_simple.py b/tests/test_simple.py
similarity index 100%
rename from test_simple.py
rename to tests/test_simple.py
diff --git a/test_videos.py b/tests/test_videos.py
similarity index 100%
rename from test_videos.py
rename to tests/test_videos.py