import torch import os import folder_paths import comfy.utils import re class PromptEmbeddingFixer: @classmethod def INPUT_TYPES(cls): return { "required": { "text": ("STRING", {"multiline": True, "dynamicPrompts": True}), } } RETURN_TYPES = ("STRING",) FUNCTION = "fix_prompt" CATEGORY = "EmbeddingToolkit/Utils" def fix_prompt(self, text): # Add space before embedding if missing text = re.sub(r'(?= 2: output_text.append(f" [CHECK] Checking single tensor fallback...") if val.shape[-1] == expected_size: output_text.append(f" [OK] Fallback match! Shape: {val.shape}") match_found = True else: output_text.append(f" [FAIL] Fallback mismatch. {val.shape[-1]} vs {expected_size}") if not match_found: output_text.append(f" [INFO] No compatible embedding found for this component.") except Exception as e: output_text.append(f" Error inspecting model component: {e}") else: output_text.append(" (No transformer found)") return {"ui": {"text": ["\n".join(output_text)]}} NODE_CLASS_MAPPINGS = { "PromptEmbeddingFixer": PromptEmbeddingFixer, "InspectEmbeddingForClip": InspectEmbeddingForClip, } NODE_DISPLAY_NAME_MAPPINGS = { "PromptEmbeddingFixer": "Prompt Embedding Fixer", "InspectEmbeddingForClip": "Inspect Embedding For Clip", }