From 82e86e625cac17e930ad697f52157cb37e00ffeb Mon Sep 17 00:00:00 2001 From: "Eric W. Burns" Date: Thu, 6 Mar 2025 21:04:46 -0500 Subject: [PATCH] random model feature multiple models to possibly load, choosing one at random --- LICENSE | 4 ++-- nodes.py | 8 ++++++++ readme.md | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index cf3094f..c67d7d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 Eric W. Burns +Copyright (c) 2024-2025 Eric Burns Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/nodes.py b/nodes.py index 2298621..065e003 100644 --- a/nodes.py +++ b/nodes.py @@ -6,6 +6,7 @@ import gc import torch import requests import time +import random class EbuLMStudioLoadModel: ERROR_NO_MODEL_FOUND = "no model by that name found" @@ -94,6 +95,13 @@ class EbuLMStudioLoadModel: def find_matching_model(self, search_term): try: + # Check if multiple search strings are provided and select one at random + if '|' in search_term: + search_options = [s.strip() for s in search_term.split('|') if s.strip()] + if search_options: + search_term = random.choice(search_options) + print(f"Multiple search strings provided. Randomly selected: '{search_term}'") + print("Fetching model list...") # Run the 'lms ls --detailed' command to get available models diff --git a/readme.md b/readme.md index c14b84e..d02c397 100644 --- a/readme.md +++ b/readme.md @@ -31,7 +31,7 @@ A collection of custom nodes for ComfyUI that provide integration with LM Studio Unloads any loaded LLMs and then loads an LLM model into LM Studio with the following parameters: - `input_string`: Input text (passed through unchanged), serves to trigger the action -- `model_search_string`: Part of the model name to search for (default: "llama"). Spaces are treated as wild cards. First matching LLM is loaded. So "nemo q5" will match "Mistral-Nemo-Instruct-2407-abliterated.Q5_K_M.gguf" for example. +- `model_search_string`: Part of the model name to search for (default: "llama"). Spaces are treated as wild cards. First matching LLM is loaded. So "nemo q5" will match "Mistral-Nemo-Instruct-2407-abliterated.Q5_K_M.gguf" for example. You can have multiple searches separated by "|" and one will be chosen at random. - `context_length`: Model context length (default: 4096) - `seed`: Random seed to ensure that this runs on each request - `unload_image_models_first`: Whether to unload ComfyUI image models before loading LLM