Compare commits

..
1 Commits
Author SHA1 Message Date
Thomas 30bab38e89 Release v2.2.3: add TAFilmGrain node and TA-FLEXMOD-LLM v2.89 2026-11-15 15:46:52 +01:00
6 changed files with 91 additions and 250 deletions
+1 -4
View File
@@ -40,12 +40,9 @@ This project was inspired by or builds upon the following open-source works:
- ComfyUI: 0.38.0
## Changelog
**v2.2.4 cleaned example workflow (`TA-FLEXMOD-LLM v2.90.json`)**
- removed leftover example prompt texts from `TA-FLEXMOD-LLM v2.90.json`
**v2.2.3 added ta_film_grain.py v1.0**
- added self-contained `TAFilmGrain` node (`🎞️ TA Film Grain`, RGB/RGBA, 1:1 parameter-compatible with `ProPostFilmGrain`)
- updated example workflow to `TA-FLEXMOD-LLM v2.90.json` using `TAFilmGrain`
- updated example workflow to `TA-FLEXMOD-LLM v2.89.json` using `TAFilmGrain`
**v2.2.2 changed ta_sageattention_toggler.py to v2.2**
- added kitchen_enable Toggle (comfy-kitchen int8_attention)
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "TA-ComfyUI-Nodes-Pack",
"author": "tmode-1960",
"description": "Custom ComfyUI nodes for advanced AI image workflows. Includes smart model loaders (FLUX, SDXL, ZImage, Qwen), LM Studio/Ollama integration, sampler presets, VRAM/RAM cleanup, and prompt utilities.",
"version": "2.2.5",
"version": "2.2.3",
"repository": "https://github.com/tmode-1960/TA-ComfyUI-Nodes-Pack",
"license": "Apache 2.0"
}
@@ -7016,10 +7016,10 @@
}
},
"widgets_values": [
""
"A stylized, warm 3D animated medium shot inside a cozy vintage living room bathed in rich golden sunset light. An elderly friendly grandfather named Thomas with fluffy white hair, a round white beard, and round black glasses stands happily facing forward. He is wearing a cozy beige cable-knit cardigan over an olive-green shirt and brown trousers. Thomas is raising one hand in a friendly, gentle waving farewell gesture toward the camera, smiling warmly with deep crow’s feet around his eyes. Perched comfortably on his other shoulder, nestled against the thick wool of the cardigan, sits the tiny fluffy pink bubblegum creature named Ilde. Ilde is pear-shaped, pastel pink, soft and squishy, with big happy shiny black eyes and a fluffy little tail, looking content and cozy. Warm glowing sunlight casting long soft shadows, dust motes floating in the amber air, cozy wooden bookshelves blurred in the background, Pixar and Disney concept art style, rich textures, heartwarming atmosphere, 8k resolution., This image is a masterpiece. The subject is sharply depicted with outstanding detail. , cm_bubblegum, cm_oldman"
],
"widgets_values_named": {
"text_0": ""
"text_0": "A stylized, warm 3D animated medium shot inside a cozy vintage living room bathed in rich golden sunset light. An elderly friendly grandfather named Thomas with fluffy white hair, a round white beard, and round black glasses stands happily facing forward. He is wearing a cozy beige cable-knit cardigan over an olive-green shirt and brown trousers. Thomas is raising one hand in a friendly, gentle waving farewell gesture toward the camera, smiling warmly with deep crow’s feet around his eyes. Perched comfortably on his other shoulder, nestled against the thick wool of the cardigan, sits the tiny fluffy pink bubblegum creature named Ilde. Ilde is pear-shaped, pastel pink, soft and squishy, with big happy shiny black eyes and a fluffy little tail, looking content and cozy. Warm glowing sunlight casting long soft shadows, dust motes floating in the amber air, cozy wooden bookshelves blurred in the background, Pixar and Disney concept art style, rich textures, heartwarming atmosphere, 8k resolution., This image is a masterpiece. The subject is sharply depicted with outstanding detail. , cm_bubblegum, cm_oldman"
},
"color": "#233",
"bgcolor": "#355"
@@ -7782,14 +7782,14 @@
}
},
"widgets_values": [
"",
"",
""
"A stylized, warm 3D animated medium shot inside a cozy vintage living room bathed in rich golden sunset light. An elderly friendly grandfather named Thomas with fluffy white hair, a round white beard, and round black glasses stands happily facing forward. He is wearing a cozy beige cable-knit cardigan over an olive-green shirt and brown trousers. Thomas is raising one hand in a friendly, gentle waving farewell gesture toward the camera, smiling warmly with deep crow’s feet around his eyes. Perched comfortably on his other shoulder, nestled against the thick wool of the cardigan, sits the tiny fluffy pink bubblegum creature named Ilde. Ilde is pear-shaped, pastel pink, soft and squishy, with big happy shiny black eyes and a fluffy little tail, looking content and cozy. Warm glowing sunlight casting long soft shadows, dust motes floating in the amber air, cozy wooden bookshelves blurred in the background, Pixar and Disney concept art style, rich textures, heartwarming atmosphere, 8k resolution.",
"This image is a masterpiece. The subject is sharply depicted with outstanding detail. ",
"human baby, human ears, closed eyes, sleepy eyes, eyelids, droopy eyes, human skin, realistic anatomy, photo, frame, white border, border, comic border, panel border, letterbox, white edges, margins, padding"
],
"widgets_values_named": {
"positive_prompt": "",
"additional_prompt": "",
"negative_prompt": ""
"positive_prompt": "A stylized, warm 3D animated medium shot inside a cozy vintage living room bathed in rich golden sunset light. An elderly friendly grandfather named Thomas with fluffy white hair, a round white beard, and round black glasses stands happily facing forward. He is wearing a cozy beige cable-knit cardigan over an olive-green shirt and brown trousers. Thomas is raising one hand in a friendly, gentle waving farewell gesture toward the camera, smiling warmly with deep crow’s feet around his eyes. Perched comfortably on his other shoulder, nestled against the thick wool of the cardigan, sits the tiny fluffy pink bubblegum creature named Ilde. Ilde is pear-shaped, pastel pink, soft and squishy, with big happy shiny black eyes and a fluffy little tail, looking content and cozy. Warm glowing sunlight casting long soft shadows, dust motes floating in the amber air, cozy wooden bookshelves blurred in the background, Pixar and Disney concept art style, rich textures, heartwarming atmosphere, 8k resolution.",
"additional_prompt": "This image is a masterpiece. The subject is sharply depicted with outstanding detail. ",
"negative_prompt": "human baby, human ears, closed eyes, sleepy eyes, eyelids, droopy eyes, human skin, realistic anatomy, photo, frame, white border, border, comic border, panel border, letterbox, white edges, margins, padding"
},
"color": "#232",
"bgcolor": "#353"
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "TA-ComfyUI-Nodes-Pack"
version = "2.2.5"
version = "2.2.3"
description = "Custom ComfyUI nodes for advanced AI image workflows. Includes smart model loaders (FLUX, SDXL, ZImage, Qwen), LM Studio/Ollama integration, sampler presets, VRAM/RAM cleanup, and prompt utilities."
readme = "README.md"
requires-python = ">=3.8"
+3 -6
View File
@@ -2,9 +2,9 @@
================================================================================
Node Name : TA Directory Captioning
Created : 2025
Modified : 2026-11-17
Modified : 2026-03-11
Copyright : © 2026, Thomas Möhrling (thomo.ART)
Version : 2.1
Version : 2.0
--------------------------------------------------------------------------------
Part of ComfyUI-TA-Nodes-Pack
License : Apache 2.0
@@ -13,9 +13,6 @@ Description:
Iterates through a directory, sends images to LM Studio or Ollama Vision
Models and saves the generated captions as .txt files alongside each image.
Uses TASmartLLM model detection logic (LMStudio + Ollama, Vision tagging).
Changelog:
2.1 2026-11-17 Filter TASmartLLM model list to local LMStudio/Ollama backends
================================================================================
"""
@@ -140,7 +137,7 @@ class TACaptioning:
Returns:
dict: ComfyUI INPUT_TYPES dictionary with all required inputs.
"""
models = [m for m in TASmartLLM.get_models() if m.startswith(("LMStudio/", "Ollama/"))] or ["No Backend"]
models = TASmartLLM.get_models()
vision_models = [m for m in models if "[Vision]" in m]
default_model = vision_models[0] if vision_models else (models[0] if models else "No Backend")
+77 -230
View File
@@ -2,24 +2,19 @@
================================================================================
Node Name : TA Smart LLM
Created : 2025
Modified : 2026-11-24
Modified : 2026-04-05
Copyright : © 2026, Thomas Möhrling (thomo.ART)
Version : 4.0
Version : 3.8
--------------------------------------------------------------------------------
Part of ComfyUI-TA-Nodes-Pack
License : Apache 2.0
Description:
Smart LLM integration for LM Studio, Ollama, and optional external
OpenAI-compatible cloud providers (via environment variables) with VRAM
management. Auto-detects vision models (tags with [Vision]), supports
image input for multimodal prompts, optional pre/post model unloading,
and model caching. Returns generated prompt text and execution status.
Changelog:
4.0 2026-11-24 Add huihui-qwen3.8-27b-abliterated to VISION_MANUAL and pass thinking_mode to LM Studio/Ollama
3.9 2026-11-17 Add optional cloud LLM providers (Gemini, OpenAI, OpenRouter, Groq) via env vars
Smart LLM integration for LM Studio and Ollama backends with VRAM management.
Auto-detects vision models (tags with [Vision]), supports image input for
multimodal prompts, optional pre/post model unloading, and model caching.
Returns generated prompt text and execution status.
================================================================================
"""
@@ -41,69 +36,13 @@ VISION_KEYWORDS = ["llava", "vision", "-vl-", "_vl_", "vl-", "vl_", "moondream",
# Manual additions (exact model names without backend prefix, lowercase)
# Example: VISION_MANUAL = {"my-vision-model-7b", "another-model-13b"}
# VISION_MANUAL = set()
VISION_MANUAL = {
"qwen3.5-9b-uncensored-hauhaucs-aggressive",
"huihui-qwen3.8-27b-abliterated",
}
# Cloud model prefixes that support multimodal image input
CLOUD_VISION_PREFIXES = ("gemini-", "gpt-4o", "gpt-4.1", "gpt-5", "claude-3", "claude-4", "pixtral")
# Non-chat model substrings to skip when listing cloud provider models
CLOUD_SKIP_MODEL_SUBSTRINGS = ("embedding", "imagen", "veo", "tts", "aqa")
# Optional OpenAI-compatible cloud providers (activated only when env var is set)
CLOUD_PROVIDERS = {
"Gemini": {
"env_var": "GEMINI_API_KEY",
"base_url": "https://generativelanguage.googleapis.com/v1beta/openai",
"fallback_models": ["gemini-3.8-flash", "gemini-3-flash-preview", "gemini-3.5-flash-lite"],
"supports_reasoning_effort": True,
},
"OpenAI": {
"env_var": "OPENAI_API_KEY",
"base_url": "https://api.openai.com/v1",
"fallback_models": ["gpt-4o", "gpt-4o-mini"],
"supports_reasoning_effort": False,
},
"OpenRouter": {
"env_var": "OPENROUTER_API_KEY",
"base_url": "https://openrouter.ai/api/v1",
"fallback_models": ["openrouter/free"],
"supports_reasoning_effort": False,
},
"Groq": {
"env_var": "GROQ_API_KEY",
"base_url": "https://api.groq.com/openai/v1",
"fallback_models": ["llama-3.3-70b-versatile"],
"supports_reasoning_effort": False,
},
}
def _get_cloud_api_key(provider: str) -> str:
"""Returns the trimmed API key for a cloud provider from environment variables."""
cfg = CLOUD_PROVIDERS.get(provider)
if not cfg:
return ""
return os.environ.get(cfg["env_var"], "").strip()
def _sanitize_error(message: str, secret: str = "") -> str:
"""Ensures an API key is never leaked in logs or status outputs."""
if secret and secret in message:
return message.replace(secret, "***")
return message
VISION_MANUAL = {"qwen3.5-9b-uncensored-hauhaucs-aggressive"}
def is_vision_model(model_id: str) -> bool:
lower = model_id.lower()
if any(kw in lower for kw in VISION_KEYWORDS):
return True
if any(lower.startswith(prefix) for prefix in CLOUD_VISION_PREFIXES) and not any(
skip in lower for skip in CLOUD_SKIP_MODEL_SUBSTRINGS
):
return True
if lower in VISION_MANUAL:
return True
return False
@@ -155,63 +94,27 @@ class TASmartLLM:
except:
pass
@classmethod
def _discover_cloud_models(cls, provider, known_provider_models):
"""
Discovers available models for a configured cloud provider.
Returns (known_set, active_set) for that provider.
"""
api_key = _get_cloud_api_key(provider)
if not api_key:
return known_provider_models, set()
cfg = CLOUD_PROVIDERS[provider]
url = f"{cfg['base_url']}/models"
headers = {"Authorization": f"Bearer {api_key}"}
try:
r = requests.get(url, headers=headers, timeout=2.0)
if r.status_code == 200:
discovered = set()
for m in r.json().get("data", []):
m_id = (m.get("id") or "").strip()
if not m_id:
continue
if m_id.startswith("models/"):
m_id = m_id[len("models/"):]
if any(skip in m_id.lower() for skip in CLOUD_SKIP_MODEL_SUBSTRINGS):
continue
discovered.add(f"{provider}/{m_id}")
if discovered:
return discovered, discovered
except Exception:
pass
if known_provider_models:
return known_provider_models, set()
fallback = {f"{provider}/{m_id}" for m_id in cfg.get("fallback_models", [])}
return fallback, set()
@classmethod
def get_models(cls):
"""
Discovers and caches available models from LM Studio (port 1234),
Ollama (port 11434), and configured cloud providers (when API key env
vars are set). Tags vision-capable models with [Vision] suffix.
Discovers and caches available models from LM Studio (port 1234) and
Ollama (port 11434). Tags vision-capable models with [Vision] suffix.
Display logic:
- All known models are always shown (prevents validation errors).
- Active models appear at the top of the list, offline models below.
- No prefix is added to model names so stored values remain stable
across restarts regardless of which backend is active.
- Per-backend cache is updated on each call if the backend responds,
so added/removed models are reflected immediately.
"""
known = cls._load_cached_models()
known_lmstudio = {m for m in known if m.startswith("LMStudio/")}
known_ollama = {m for m in known if m.startswith("Ollama/")}
known_cloud = {
p: {m for m in known if m.startswith(f"{p}/")}
for p in CLOUD_PROVIDERS
}
active_lmstudio = set()
active_ollama = set()
active_cloud = set()
# Query LM Studio — replace cache if reachable
try:
@@ -231,23 +134,10 @@ class TASmartLLM:
except:
pass
# Query configured cloud providers (only when env var is set)
visible_cloud_known = set()
all_cloud_known = set()
for provider in CLOUD_PROVIDERS:
p_known, p_active = cls._discover_cloud_models(provider, known_cloud[provider])
all_cloud_known |= p_known
if _get_cloud_api_key(provider):
visible_cloud_known |= p_known
active_cloud |= p_active
cls._save_cached_models(known_lmstudio | known_ollama)
cls._save_cached_models(known_lmstudio | known_ollama | all_cloud_known)
active_all = active_lmstudio | active_ollama | active_cloud
visible_all = known_lmstudio | known_ollama | visible_cloud_known
active = sorted(active_all)
offline = sorted(visible_all - active_all)
active = sorted(active_lmstudio | active_ollama)
offline = sorted((known_lmstudio | known_ollama) - (active_lmstudio | active_ollama))
# Active models first, offline models after — no prefix in stored value
result = [tag_model(m) for m in active] + [tag_model(m) for m in offline]
@@ -361,26 +251,24 @@ class TASmartLLM:
img.save(buffer, 'PNG')
return base64.b64encode(buffer.getvalue()).decode('utf-8')
def _post_with_retry(self, url, payload, is_openai, headers=None, max_retries=3, retry_delay=1.5, timeout=120):
def _post_with_retry(self, url, payload, is_lmstudio, max_retries=3, retry_delay=1.5, timeout=120):
"""
Posts to LLM API with retry logic for transient errors (including 429 rate limits).
For OpenAI-compatible APIs returns the full message dict; for Ollama returns the response string.
Posts to LLM API with retry logic for transient errors.
For LM Studio returns the full message dict; for Ollama returns the response string.
"""
last_error = None
for attempt in range(1, max_retries + 1):
try:
r = requests.post(url, json=payload, headers=headers, timeout=timeout)
r = requests.post(url, json=payload, timeout=timeout)
r.raise_for_status()
if is_openai:
if is_lmstudio:
return r.json()['choices'][0]['message'] # Return full message dict
else:
return r.json()['response']
except requests.exceptions.HTTPError as e:
last_error = e
status_code = e.response.status_code if e.response is not None else None
if status_code in (400, 429, 500, 502, 503) and attempt < max_retries:
delay = retry_delay * attempt if status_code == 429 else retry_delay
time.sleep(delay)
if e.response is not None and e.response.status_code in (400, 500, 502, 503) and attempt < max_retries:
time.sleep(retry_delay)
continue
raise
except requests.exceptions.RequestException as e:
@@ -391,47 +279,6 @@ class TASmartLLM:
raise
raise last_error
def _build_openai_payload(self, model_name, system_prompt, full_prompt, img_b64,
temperature, max_tokens, extra_params=None):
"""Builds a standard OpenAI-compatible /chat/completions payload."""
if img_b64:
user_content = [
{"type": "text", "text": full_prompt},
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}}
]
else:
user_content = full_prompt
payload = {
"model": model_name,
"messages": [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_content}
],
"temperature": temperature,
"max_tokens": max_tokens
}
if extra_params:
payload.update(extra_params)
return payload
def _extract_openai_response(self, message, thinking_mode):
"""Extracts (result, reasoning) from an OpenAI-compatible message dict."""
content = (message.get('content') or '').strip()
reasoning = (message.get('reasoning_content') or '').strip()
if thinking_mode:
# Thinking ON -> return full content including thinking
result = content if content else reasoning
else:
# Thinking OFF -> return only the final answer, strip thinking
if content:
result = content.split("</think>", 1)[-1].strip() if "</think>" in content else content
else:
result = reasoning.split("</think>", 1)[-1].strip() if "</think>" in reasoning else ""
return result, reasoning
def generate(self, llm_enable, model, user_prompt, system_prompt,
temperature=0.7, max_tokens=1024, request_timeout=120,
thinking_mode=False,
@@ -441,19 +288,19 @@ class TASmartLLM:
Main generation method. Queries the selected LLM and returns prompt + status.
Workflow:
1. Skip if disabled or backend unreachable / API key missing.
1. Skip if disabled or backend unreachable.
2. Optionally unload ComfyUI models for VRAM.
3. Build payload (text + optional image b64).
4. Send request to LM Studio, Ollama, or configured cloud provider with retries.
5. Optionally unload local LLM model after.
4. Send request to LM Studio/Ollama with retries.
5. Optionally unload LLM model after.
Args:
llm_enable (bool): Master enable toggle.
model (str): Selected model (tagged).
user_prompt (str): User input.
system_prompt (str): System instruction.
unload_image_models_first (bool): Free VRAM before.
unload_llm_after (bool): Free VRAM after (local backends only).
unload_llm_after (bool): Free VRAM after.
image: Optional IMAGE for vision models.
Returns:
@@ -465,18 +312,10 @@ class TASmartLLM:
clean_model = strip_vision_tag(model)
backend = clean_model.split('/')[0]
model_name = '/'.join(clean_model.split('/')[1:])
is_cloud = backend in CLOUD_PROVIDERS
api_key = ""
port = 1234 if "LMStudio" in backend else 11434
if is_cloud:
api_key = _get_cloud_api_key(backend)
if not api_key:
env_var = CLOUD_PROVIDERS[backend]["env_var"]
return ("", f"SKIPPED - {backend} API key ({env_var}) not set", "")
else:
port = 1234 if "LMStudio" in backend else 11434
if not self._backend_reachable(backend, port):
return ("", f"SKIPPED - {backend} not reachable", "")
if not self._backend_reachable(backend, port):
return ("", f"SKIPPED - {backend} not reachable", "")
print(f"[TA Smart LLM] Loading model: {clean_model}")
@@ -485,40 +324,49 @@ class TASmartLLM:
self._unload_comfyui_models()
full_prompt = user_prompt.strip()
img_b64 = self._build_image_b64(image) if image is not None else None
try:
if is_cloud:
cfg = CLOUD_PROVIDERS[backend]
url = f"{cfg['base_url']}/chat/completions"
headers = {"Authorization": f"Bearer {api_key}"}
extra_params = None
if cfg.get("supports_reasoning_effort") and not thinking_mode:
extra_params = {"reasoning_effort": "none"}
payload = self._build_openai_payload(
model_name, system_prompt, full_prompt, img_b64,
temperature, max_tokens, extra_params=extra_params
)
message = self._post_with_retry(
url, payload, is_openai=True, headers=headers, timeout=request_timeout
)
result, reasoning = self._extract_openai_response(message, thinking_mode)
elif "LMStudio" in backend:
if "LMStudio" in backend:
url = f"http://127.0.0.1:{port}/v1/chat/completions"
extra_params = (
{"chat_template_kwargs": {"enable_thinking": False}}
if not thinking_mode else None
)
payload = self._build_openai_payload(
model_name, system_prompt, full_prompt, img_b64,
temperature, max_tokens, extra_params=extra_params
)
message = self._post_with_retry(
url, payload, is_openai=True, timeout=request_timeout
)
result, reasoning = self._extract_openai_response(message, thinking_mode)
if img_b64:
user_content = [
{"type": "text", "text": full_prompt},
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}}
]
else:
user_content = full_prompt
payload = {
"model": model_name,
"messages": [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_content}
],
"temperature": temperature,
"max_tokens": max_tokens
}
message = self._post_with_retry(url, payload, is_lmstudio=True, timeout=request_timeout)
content = (message.get('content') or '').strip()
reasoning = (message.get('reasoning_content') or '').strip()
if thinking_mode:
# Thinking ON → return full content including thinking
result = content if content else reasoning
else:
# Thinking OFF → return only the final answer, strip thinking
if content:
if "</think>" in content:
result = content.split("</think>", 1)[-1].strip()
else:
result = content
else:
if "</think>" in reasoning:
result = reasoning.split("</think>", 1)[-1].strip()
else:
result = "" # Pure thinking block, no answer
# Unload LM Studio model after request
if unload_llm_after:
@@ -530,7 +378,6 @@ class TASmartLLM:
"model": model_name,
"prompt": f"{system_prompt}\n\n{full_prompt}".strip(),
"stream": False,
"think": bool(thinking_mode),
"options": {
"temperature": temperature,
"num_predict": max_tokens
@@ -539,7 +386,7 @@ class TASmartLLM:
if img_b64:
payload["images"] = [img_b64]
result = self._post_with_retry(url, payload, is_openai=False, timeout=request_timeout)
result = self._post_with_retry(url, payload, is_lmstudio=False, timeout=request_timeout)
reasoning = ""
# Ollama: strip <think> tags if thinking is OFF
@@ -557,8 +404,8 @@ class TASmartLLM:
return ("", f"WARNING: {clean_model} returned empty response", reasoning)
except Exception as e:
return (f"ERROR: {_sanitize_error(str(e), api_key)}", clean_model, "")
return (f"ERROR: {str(e)}", clean_model, "")
NODE_CLASS_MAPPINGS = {"TASmartLLM": TASmartLLM}
NODE_DISPLAY_NAME_MAPPINGS = {"TASmartLLM": "TA Smart LLM v3.9"}
NODE_DISPLAY_NAME_MAPPINGS = {"TASmartLLM": "TA Smart LLM v3.8"}