feat: Release v1.0.6 with 6 new advanced text nodes and Nodes 2.0 (Vue UI) optimization
This commit is contained in:
@@ -51,13 +51,21 @@ class FeiMao_326_GeneralAPINode:
|
||||
"required": {
|
||||
"api_baseurl": ("STRING", {"multiline": False, "default": "http://127.0.0.1:11434/v1"}),
|
||||
"api_key": ("STRING", {"multiline": False, "default": "ollama"}),
|
||||
<<<<<<< HEAD
|
||||
"model": ("STRING", {"multiline": False, "default": "gemma3:4b"}),
|
||||
=======
|
||||
"model": ("STRING", {"multiline": False, "default": "gemma4:e4b"}),
|
||||
>>>>>>> e9ec5ee (feat: Release v1.0.6 with 6 new advanced text nodes and Nodes 2.0 (Vue UI) optimization)
|
||||
"role": ("STRING", {"multiline": True, "default": "You are a helpful assistant. Follow the user's instructions exactly. Output only the requested content without conversational filler, markdown formatting, or explanations."}),
|
||||
"prompt": ("STRING", {"multiline": True, "default": "Describe this image in detail."}),
|
||||
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": s.MAX_SEED}),
|
||||
"temperature": ("FLOAT", {"default": 0.6, "min": 0.0, "max": 2.0, "step": 0.01}),
|
||||
<<<<<<< HEAD
|
||||
"max_tokens": ("INT", {"default": 4096, "min": 64, "max": 16384, "step": 64}),
|
||||
=======
|
||||
"max_tokens": ("INT", {"default": 4096, "min": 64, "max": 131072, "step": 512}),
|
||||
>>>>>>> e9ec5ee (feat: Release v1.0.6 with 6 new advanced text nodes and Nodes 2.0 (Vue UI) optimization)
|
||||
"control_after_generate": (["fixed", "increment", "decrement", "randomize"],),
|
||||
"cleanup_local_gpu": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
@@ -114,6 +122,7 @@ class FeiMao_326_GeneralAPINode:
|
||||
"""Returns a 1x1x3 black image tensor"""
|
||||
return torch.zeros((1, 1, 1, 3), dtype=torch.float32)
|
||||
|
||||
<<<<<<< HEAD
|
||||
def cleanup_with_ollama_cli(self, model):
|
||||
command = ['ollama', 'stop', model]
|
||||
print(f"🔵 [FeiMao-326 API Node] Attempting to unload local model via CLI: {' '.join(command)}")
|
||||
@@ -136,6 +145,60 @@ class FeiMao_326_GeneralAPINode:
|
||||
print("❌ [FeiMao-326 API Node] Error: 'ollama' command not found. Please ensure Ollama is installed correctly.")
|
||||
except Exception as e:
|
||||
print(f"⚠️ [FeiMao-326 API Node] An error occurred while executing the CLI command: {str(e)}")
|
||||
=======
|
||||
def cleanup_ollama_model(self, api_baseurl, model):
|
||||
"""
|
||||
Unloads an Ollama model from memory.
|
||||
1. Primary attempt: Native REST API with keep_alive: 0 (No environment variables required).
|
||||
2. Fallback: CLI 'ollama stop' command (Depends on system PATH).
|
||||
"""
|
||||
model_unloaded = False
|
||||
|
||||
# --- 1. PRIMARY: REST API UNLOAD ---
|
||||
try:
|
||||
# Construct Ollama native generate URL (usually /v1 -> /api/generate)
|
||||
# Example: http://127.0.0.1:11434/v1 -> http://127.0.0.1:11434/api/generate
|
||||
if "/v1" in api_baseurl:
|
||||
unload_url = api_baseurl.replace("/v1", "/api/generate").rstrip("/")
|
||||
else:
|
||||
# If it's a custom URL, try to guess the root
|
||||
from urllib.parse import urlparse
|
||||
parsed = urlparse(api_baseurl)
|
||||
unload_url = f"{parsed.scheme}://{parsed.netloc}/api/generate"
|
||||
|
||||
print(f"🔵 [FeiMao-326 API Node] Attempting to unload model '{model}' via REST API...")
|
||||
payload = {
|
||||
"model": model,
|
||||
"keep_alive": 0 # Unload immediately
|
||||
}
|
||||
response = requests.post(unload_url, json=payload, timeout=5)
|
||||
|
||||
if response.status_code == 200:
|
||||
print(f"✅ [FeiMao-326 API Node] Model '{model}' successfully unloaded via API.")
|
||||
model_unloaded = True
|
||||
else:
|
||||
print(f"⚠️ [FeiMao-326 API Node] API unload status: {response.status_code}. Falling back to CLI.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"⚠️ [FeiMao-326 API Node] REST API unload failed ({type(e).__name__}). Falling back to CLI.")
|
||||
|
||||
# --- 2. FALLBACK: CLI COMMAND ---
|
||||
if not model_unloaded:
|
||||
command = ['ollama', 'stop', model]
|
||||
print(f"🔵 [FeiMao-326 API Node] Attempting to unload via CLI: {' '.join(command)}")
|
||||
try:
|
||||
result = subprocess.run(command, capture_output=True, timeout=10, check=False)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"✅ [FeiMao-326 API Node] Model '{model}' successfully stopped via CLI.")
|
||||
else:
|
||||
stderr_output = result.stderr.decode(locale.getpreferredencoding(), errors='replace')
|
||||
print(f"❌ [FeiMao-326 API Node] CLI stop failed: {stderr_output.strip()}")
|
||||
except FileNotFoundError:
|
||||
print("❌ [FeiMao-326 API Node] Error: 'ollama' command not found. Environment variable may not be configured.")
|
||||
except Exception as e:
|
||||
print(f"⚠️ [FeiMao-326 API Node] CLI stop error: {str(e)}")
|
||||
>>>>>>> e9ec5ee (feat: Release v1.0.6 with 6 new advanced text nodes and Nodes 2.0 (Vue UI) optimization)
|
||||
|
||||
def execute(self, api_baseurl, api_key, model, role, prompt, seed, temperature, max_tokens, control_after_generate,
|
||||
cleanup_local_gpu=True, image_1=None, image_2=None, image_3=None, **kwargs):
|
||||
@@ -143,6 +206,14 @@ class FeiMao_326_GeneralAPINode:
|
||||
current_seed = self._normalize_seed(seed)
|
||||
generated_image_tensor = self.get_empty_image() # Default empty image
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
# --- 0. AUTO-MAPPING DEPRECATED MODELS ---
|
||||
if "gemini-3-pro-preview" in model.lower():
|
||||
print(f"⚠️ [FeiMao_326 API Node] Model 'gemini-3-pro-preview' is deprecated. Auto-redirecting to 'gemini-3.1-pro'.")
|
||||
model = model.replace("gemini-3-pro-preview", "gemini-3.1-pro")
|
||||
|
||||
>>>>>>> e9ec5ee (feat: Release v1.0.6 with 6 new advanced text nodes and Nodes 2.0 (Vue UI) optimization)
|
||||
# Enforce silent role if empty or default
|
||||
if not role or not role.strip():
|
||||
role = "You are a helpful assistant. Follow the user's instructions exactly. Output only the requested content without conversational filler."
|
||||
@@ -367,7 +438,11 @@ class FeiMao_326_GeneralAPINode:
|
||||
finally:
|
||||
is_local_ollama = "127.0.0.1" in api_baseurl or "localhost" in api_baseurl
|
||||
if cleanup_local_gpu and is_local_ollama:
|
||||
<<<<<<< HEAD
|
||||
self.cleanup_with_ollama_cli(model)
|
||||
=======
|
||||
self.cleanup_ollama_model(api_baseurl, model)
|
||||
>>>>>>> e9ec5ee (feat: Release v1.0.6 with 6 new advanced text nodes and Nodes 2.0 (Vue UI) optimization)
|
||||
if TORCH_AVAILABLE and torch.cuda.is_available():
|
||||
print(f"🔵 [FeiMao-326 API Node] Clearing PyTorch GPU cache...")
|
||||
torch.cuda.empty_cache()
|
||||
|
||||
Reference in New Issue
Block a user