From 6648f31c553d5e0abd6f1f35f19f97eca99d0307 Mon Sep 17 00:00:00 2001 From: Octopus Date: Sun, 5 Apr 2026 13:12:39 +0800 Subject: [PATCH] fix: raise clear error when non-LLM model is used with TextGenerate node (fixes #13286) When a user connects a CLIP text encoder (e.g. CLIPTextModel) to the TextGenerate node instead of a language model (LLM), the previous behavior was an unhelpful AttributeError. Now a RuntimeError is raised with a clear explanation of what model type is required. --- comfy/sd.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/comfy/sd.py b/comfy/sd.py index 5b6b59ea4..f12f0f31d 100644 --- a/comfy/sd.py +++ b/comfy/sd.py @@ -424,6 +424,12 @@ class CLIP: return self.patcher.get_key_patches() def generate(self, tokens, do_sample=True, max_length=256, temperature=1.0, top_k=50, top_p=0.95, min_p=0.0, repetition_penalty=1.0, seed=None, presence_penalty=0.0): + if not hasattr(self.cond_stage_model, 'generate'): + raise RuntimeError( + f"The loaded model ({type(self.cond_stage_model).__name__}) does not support text generation. " + "The TextGenerate node requires a language model (LLM) such as Qwen, LLaMA, or Gemma, " + "not a CLIP text encoder. Please load the correct model type." + ) self.cond_stage_model.reset_clip_options() self.load_model(tokens)