Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bfd2ac65f | ||
|
|
56aa1bef12 | ||
|
|
b4a82be05b | ||
|
|
7445bc4971 | ||
|
|
e022b92ef1 | ||
|
|
7d807b5728 | ||
|
|
f6633f19e4 |
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "TA-ComfyUI-Nodes-Pack",
|
||||
"author": "tmode-1960",
|
||||
"description": "Some useful nodes for ComfyUI (Model Loader, LM Studio, Ollama and more)",
|
||||
"version": "2.0.0",
|
||||
"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.0.1",
|
||||
"repository": "https://github.com/tmode-1960/TA-ComfyUI-Nodes-Pack",
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
[project]
|
||||
name = "TA-ComfyUI-Nodes-Pack"
|
||||
version = "2.0.0"
|
||||
description = "Some useful nodes for ComfyUI (Model Loader, LM Studio, Ollama and more))"
|
||||
version = "2.0.1"
|
||||
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"
|
||||
license = {text = "MIT"}
|
||||
license = {text = "Apache-2.0"}
|
||||
authors = [
|
||||
{name = "tmode-1960", email = "info@thomo.art"}
|
||||
]
|
||||
|
||||
+44
-36
@@ -2,9 +2,9 @@
|
||||
================================================================================
|
||||
Node Name : TA Smart LLM
|
||||
Created : 2025
|
||||
Modified : 2026-03-13
|
||||
Modified : 2026-03-16
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 2.2
|
||||
Version : 3.0
|
||||
--------------------------------------------------------------------------------
|
||||
Part of ComfyUI-TA-Nodes-Pack
|
||||
License : Apache 2.0
|
||||
@@ -99,39 +99,48 @@ class TASmartLLM:
|
||||
Discovers and caches available models from LM Studio (port 1234) and
|
||||
Ollama (port 11434). Tags vision-capable models with [Vision] suffix.
|
||||
|
||||
Per-backend logic:
|
||||
- If a backend responds, its models replace the cached entries for
|
||||
that backend (additions and deletions are reflected immediately).
|
||||
- If a backend is offline, its cached entries are kept unchanged so
|
||||
that saved workflows remain valid without breaking validation.
|
||||
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()
|
||||
|
||||
# Split cache by backend
|
||||
known_lmstudio = {m for m in known if m.startswith("LMStudio/")}
|
||||
known_ollama = {m for m in known if m.startswith("Ollama/")}
|
||||
|
||||
active_lmstudio = set()
|
||||
active_ollama = set()
|
||||
|
||||
# Query LM Studio — replace cache if reachable
|
||||
try:
|
||||
r = requests.get("http://127.0.0.1:1234/v1/models", timeout=2)
|
||||
r = requests.get("http://127.0.0.1:1234/v1/models", timeout=0.5)
|
||||
if r.status_code == 200:
|
||||
known_lmstudio = {f"LMStudio/{m['id']}" for m in r.json()['data']}
|
||||
active_lmstudio = known_lmstudio
|
||||
except:
|
||||
pass # offline — keep existing cache
|
||||
pass
|
||||
|
||||
# Query Ollama — replace cache if reachable
|
||||
try:
|
||||
r = requests.get("http://127.0.0.1:11434/api/tags", timeout=2)
|
||||
r = requests.get("http://127.0.0.1:11434/api/tags", timeout=0.5)
|
||||
if r.status_code == 200:
|
||||
known_ollama = {f"Ollama/{m['name']}" for m in r.json()['models']}
|
||||
active_ollama = known_ollama
|
||||
except:
|
||||
pass # offline — keep existing cache
|
||||
pass
|
||||
|
||||
all_models = known_lmstudio | known_ollama
|
||||
cls._save_cached_models(all_models)
|
||||
cls._save_cached_models(known_lmstudio | known_ollama)
|
||||
|
||||
tagged = [tag_model(m) for m in sorted(all_models)]
|
||||
return tagged if tagged else ["No Backend"]
|
||||
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]
|
||||
return result if result else ["No Backend"]
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -159,6 +168,8 @@ class TASmartLLM:
|
||||
"model": (models, {"default": models[0] if models else "No Backend"}),
|
||||
"user_prompt": ("STRING", {"multiline": True, "default": ""}),
|
||||
"system_prompt": ("STRING", {"multiline": True, "default": "You are an expert SD prompt generator."}),
|
||||
"temperature": ("FLOAT", {"default": 0.7, "min": 0.0, "max": 2.0, "step": 0.05}),
|
||||
"max_tokens": ("INT", {"default": 1024, "min": 64, "max": 8192, "step": 64}),
|
||||
"unload_image_models_first": ("BOOLEAN", {"default": False}),
|
||||
"unload_llm_after": ("BOOLEAN", {"default": False}),
|
||||
},
|
||||
@@ -173,7 +184,13 @@ class TASmartLLM:
|
||||
CATEGORY = "TA Tools"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, *args, **kwargs):
|
||||
def IS_CHANGED(cls, llm_enable, model, user_prompt, system_prompt,
|
||||
temperature=0.7, max_tokens=1024,
|
||||
unload_image_models_first=False, unload_llm_after=False,
|
||||
image=None):
|
||||
# Wenn deaktiviert: fixer Wert → Node wird von ComfyUI gecacht, kein erneuter Aufruf
|
||||
if not llm_enable:
|
||||
return "disabled"
|
||||
return time.time()
|
||||
|
||||
def _backend_reachable(self, backend, port):
|
||||
@@ -182,7 +199,7 @@ class TASmartLLM:
|
||||
"""
|
||||
try:
|
||||
url = f"http://127.0.0.1:{port}/v1/models" if "LMStudio" in backend else f"http://127.0.0.1:{port}/api/tags"
|
||||
return requests.get(url, timeout=2).status_code == 200
|
||||
return requests.get(url, timeout=0.5).status_code == 200
|
||||
except:
|
||||
return False
|
||||
|
||||
@@ -230,20 +247,6 @@ class TASmartLLM:
|
||||
img.save(buffer, 'PNG')
|
||||
return base64.b64encode(buffer.getvalue()).decode('utf-8')
|
||||
|
||||
def _flush_lmstudio_context(self, url, model_name):
|
||||
"""
|
||||
Sends a minimal request to clear LM Studio chat context.
|
||||
"""
|
||||
try:
|
||||
requests.post(url, json={
|
||||
"model": model_name,
|
||||
"messages": [{"role": "user", "content": "."}],
|
||||
"max_tokens": 1
|
||||
}, timeout=10)
|
||||
except:
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
|
||||
def _post_with_retry(self, url, payload, is_lmstudio, max_retries=3, retry_delay=1.5):
|
||||
"""
|
||||
Posts to LLM API with retry logic for transient errors.
|
||||
@@ -269,6 +272,7 @@ class TASmartLLM:
|
||||
raise last_error
|
||||
|
||||
def generate(self, llm_enable, model, user_prompt, system_prompt,
|
||||
temperature=0.7, max_tokens=1024,
|
||||
unload_image_models_first=False, unload_llm_after=False,
|
||||
image=None):
|
||||
"""
|
||||
@@ -318,7 +322,6 @@ class TASmartLLM:
|
||||
if "LMStudio" in backend:
|
||||
url = f"http://127.0.0.1:{port}/v1/chat/completions"
|
||||
if img_b64:
|
||||
self._flush_lmstudio_context(url, model_name)
|
||||
user_content = [
|
||||
{"type": "text", "text": full_prompt},
|
||||
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}}
|
||||
@@ -331,7 +334,8 @@ class TASmartLLM:
|
||||
{"role": "system", "content": system_prompt},
|
||||
{"role": "user", "content": user_content}
|
||||
],
|
||||
"max_tokens": 1024
|
||||
"temperature": temperature,
|
||||
"max_tokens": max_tokens
|
||||
}
|
||||
|
||||
result = self._post_with_retry(url, payload, is_lmstudio=True)
|
||||
@@ -345,7 +349,11 @@ class TASmartLLM:
|
||||
payload = {
|
||||
"model": model_name,
|
||||
"prompt": f"{system_prompt}\n\n{full_prompt}".strip(),
|
||||
"stream": False
|
||||
"stream": False,
|
||||
"options": {
|
||||
"temperature": temperature,
|
||||
"num_predict": max_tokens
|
||||
}
|
||||
}
|
||||
|
||||
if img_b64:
|
||||
@@ -363,4 +371,4 @@ class TASmartLLM:
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {"TASmartLLM": TASmartLLM}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {"TASmartLLM": "TA Smart LLM v2.2"}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {"TASmartLLM": "TA Smart LLM v3.0"}
|
||||
|
||||
@@ -1 +1 @@
|
||||
["LMStudio/cognitivecomputations_dolphin-mistral-24b-venice-edition", "LMStudio/cydonia-24b-v4.1", "LMStudio/deepseek-coder-v2-lite-16b", "LMStudio/gemma-3-27b-it-qat", "LMStudio/huihui-qwen3-vl-8b-instruct-abliterated", "LMStudio/llama-3.1-unhinged-vision-8b", "LMStudio/llama-3.2-1b-instruct", "LMStudio/llava-v1.5-7b-llamafile", "LMStudio/mistral-catmacaroni-slerp-uncensored-7b", "LMStudio/mistral-small-3.1-draft-0.5b", "LMStudio/mistralai/devstral-small-2-2512", "LMStudio/mistralai/ministral-3-14b-reasoning", "LMStudio/qwen2.5-0.5b-instruct", "LMStudio/qwen2.5-0.5b-song-lyrics-generation", "LMStudio/qwen3-30b-a3b-thinking-2507-claude-4.5-sonnet-high-reasoning-distill", "LMStudio/qwen3-4b-thinking-2507", "LMStudio/qwen3-coder-30b-a3b-instruct", "LMStudio/qwen3-vl-8b-instruct", "LMStudio/text-embedding-nomic-embed-text-v1.5", "LMStudio/wizardlm-1.0-uncensored-llama2-13b", "LMStudio/xortron2025"]
|
||||
[]
|
||||
|
||||
Reference in New Issue
Block a user