Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d05925c9bc | ||
|
|
d7ff4ac68a | ||
|
|
c239b879cd | ||
|
|
9448123178 | ||
|
|
6761cdfac4 | ||
|
|
f4caaba828 | ||
|
|
5c5a99119e | ||
|
|
23e6d5d3e4 | ||
|
|
4513d481d0 | ||
|
|
cf79c3edd4 | ||
|
|
43ddf78333 | ||
|
|
b2e5d91a8c | ||
|
|
3757156700 | ||
|
|
ca096a9027 | ||
|
|
5c68c8006c | ||
|
|
2bfd2ac65f | ||
|
|
56aa1bef12 | ||
|
|
b4a82be05b | ||
|
|
7445bc4971 | ||
|
|
e022b92ef1 | ||
|
|
7d807b5728 | ||
|
|
f6633f19e4 |
+8
-1
@@ -1 +1,8 @@
|
||||
__pycache__
|
||||
__pycache__
|
||||
|
||||
# Nutzerspezifische Konfigurationsdateien – nicht durch Updates überschreiben
|
||||
ta_discord_link.json
|
||||
ta_model_choices.json
|
||||
ta_model_presets.json
|
||||
ta_sampler_presets.json
|
||||
ta_smart_llm_models.json
|
||||
|
||||
@@ -16,7 +16,36 @@ A collection of nodes designed for use in thomo.ART workflows, focused on flexib
|
||||
The full documentation is available via the built-in **Help button** in each node (opens in your browser at `http://localhost:8188/ta-nodes/wiki/index.html`).
|
||||
|
||||
---
|
||||
## Credits
|
||||
This project was inspired by or builds upon the following open-source works:
|
||||
|
||||
- **[ComfyUI-EBU-LMStudio](https://github.com/burnsbert/ComfyUI-EBU-LMStudio)** by [burnsbert (Eric W. Burns)](https://github.com/burnsbert)
|
||||
Inspiration for the LM Studio / LLM integration in ComfyUI, implemented in the **TASmartLLM** node with support for both LM Studio and Ollama.
|
||||
|
||||
- **[Comfyui-Memory_Cleanup](https://github.com/LAOGOU-666/Comfyui-Memory_Cleanup)** by [LAOGOU-666](https://github.com/LAOGOU-666)
|
||||
Inspiration for the VRAM and RAM cleanup logic in the **TACleanupSwitch** node.
|
||||
---
|
||||
|
||||
## Changelog
|
||||
**v2.0.6 changed ta_smart_llm to v3.2**
|
||||
- `request_timeout` is built as an INT widget between `max_tokens` and `unload_image_models_first` — default 120s, adjustable from 30 to 600s in increments of 30.
|
||||
|
||||
**v2.0.5 changed .gitignore**
|
||||
- All JSON files have been added to Gitignore so that they will no longer be overwritten during an update.
|
||||
|
||||
**v2.0.3 changed ta_smart_llm**
|
||||
ta_smart_llm v3.1:
|
||||
- `unload_image_models_first` and `unload_llm_after` now default to `True`. Note that existing nodes in the workflow retain their saved values—the new default only applies to newly placed nodes.
|
||||
|
||||
**v2.0.2 changed ta_smart_llm**
|
||||
ta_smart_llm v3.0 is the consolidated version with all fixes:
|
||||
- Active models are now displayed at the top of the dropdown, offline models at the bottom — no validation error
|
||||
- timeout=0.5 for all backend queries
|
||||
- IS_CHANGED returns "disabled" if llm_enable=False — the node is cached
|
||||
- _flush_lmstudio_context removed — saves the 0.5s pause before vision requests
|
||||
- temperature + max_tokens as configurable parameters
|
||||
|
||||
---
|
||||
## Nodes
|
||||
|
||||
### 🧠 TA Unified Model Switcher
|
||||
@@ -69,7 +98,7 @@ Displays a clickable Discord invite link directly inside the ComfyUI graph. URL
|
||||
## Installation
|
||||
|
||||
### Via ComfyUI Manager
|
||||
Search for `TA-ComfyUI-Nodes-Pack` in the ComfyUI Manager and install.
|
||||
Search for `TA ComfyUI Nodes Pack` in the ComfyUI Manager and install.
|
||||
|
||||
### Manual
|
||||
```bash
|
||||
|
||||
+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.6",
|
||||
"repository": "https://github.com/tmode-1960/TA-ComfyUI-Nodes-Pack",
|
||||
"license": "Apache 2.0"
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+4
-4
@@ -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.6"
|
||||
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"}
|
||||
]
|
||||
@@ -27,5 +27,5 @@ build-backend = "setuptools.build_meta"
|
||||
# ComfyUI Registry Konfiguration
|
||||
[tool.comfy]
|
||||
PublisherId = "tmode-1960"
|
||||
DisplayName = "TA ComfyUI Nodes Pack"
|
||||
DisplayName = "TA-ComfyUI-Nodes-Pack"
|
||||
Icon = "" # Optional: URL zu einem Icon
|
||||
|
||||
+51
-42
@@ -2,9 +2,9 @@
|
||||
================================================================================
|
||||
Node Name : TA Smart LLM
|
||||
Created : 2025
|
||||
Modified : 2026-03-13
|
||||
Modified : 2026-03-21
|
||||
Copyright : © 2026, Thomas Möhrling (thomo.ART)
|
||||
Version : 2.2
|
||||
Version : 3.2
|
||||
--------------------------------------------------------------------------------
|
||||
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,8 +168,11 @@ 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."}),
|
||||
"unload_image_models_first": ("BOOLEAN", {"default": False}),
|
||||
"unload_llm_after": ("BOOLEAN", {"default": False}),
|
||||
"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}),
|
||||
"request_timeout": ("INT", {"default": 120, "min": 30, "max": 600, "step": 30}),
|
||||
"unload_image_models_first": ("BOOLEAN", {"default": True}),
|
||||
"unload_llm_after": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
"optional": {
|
||||
"image": ("IMAGE",)
|
||||
@@ -173,7 +185,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, request_timeout=120,
|
||||
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 +200,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,28 +248,14 @@ 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):
|
||||
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.
|
||||
"""
|
||||
last_error = None
|
||||
for attempt in range(1, max_retries + 1):
|
||||
try:
|
||||
r = requests.post(url, json=payload, timeout=120)
|
||||
r = requests.post(url, json=payload, timeout=timeout)
|
||||
r.raise_for_status()
|
||||
return r.json()['choices'][0]['message']['content'] if is_lmstudio else r.json()['response']
|
||||
except requests.exceptions.HTTPError as e:
|
||||
@@ -269,6 +273,7 @@ class TASmartLLM:
|
||||
raise last_error
|
||||
|
||||
def generate(self, llm_enable, model, user_prompt, system_prompt,
|
||||
temperature=0.7, max_tokens=1024, request_timeout=120,
|
||||
unload_image_models_first=False, unload_llm_after=False,
|
||||
image=None):
|
||||
"""
|
||||
@@ -318,7 +323,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,10 +335,11 @@ 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)
|
||||
result = self._post_with_retry(url, payload, is_lmstudio=True, timeout=request_timeout)
|
||||
|
||||
# Unload LM Studio model after request
|
||||
if unload_llm_after:
|
||||
@@ -345,12 +350,16 @@ 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:
|
||||
payload["images"] = [img_b64]
|
||||
result = self._post_with_retry(url, payload, is_lmstudio=False)
|
||||
result = self._post_with_retry(url, payload, is_lmstudio=False, timeout=request_timeout)
|
||||
|
||||
# Unload Ollama model after request
|
||||
if unload_llm_after:
|
||||
@@ -363,4 +372,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.2"}
|
||||
|
||||
@@ -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