Add files via upload

Uploading files for Endless Nodes V1.0
This commit is contained in:
tusharbhutt
2025-06-21 18:51:00 -06:00
committed by GitHub
parent 4a202db6db
commit df0c9d20c2
20 changed files with 2510 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
from .endless_random_prompt_selectors import (
EndlessNode_RandomPromptSelector,
EndlessNode_RandomPromptMultiPicker,
)
NODE_CLASS_MAPPINGS = {
"Random_Prompt_Selector": EndlessNode_RandomPromptSelector,
"Random_Prompt_Multipicker": EndlessNode_RandomPromptMultiPicker,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"Random_Prompt_Selector": "Random Prompt Selector",
"Random_Prompt_Multipicker": "Random Multiprompt Picker"
}

View File

@@ -0,0 +1,107 @@
import random
import time
class EndlessNode_RandomPromptSelector:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"prompts": ("STRING", {
"multiline": True,
"default": "Prompt A\nPrompt B\nPrompt C"
}),
"seed": ("INT", {
"default": 0,
"min": 0,
"max": 2**32 - 1
}),
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("selected_prompt",)
FUNCTION = "pick_random_prompt"
CATEGORY = "Endless 🌊✨/Randomizers"
def pick_random_prompt(self, prompts, seed):
# Use the seed to ensure reproducible randomness
random.seed(seed)
lines = [line.strip() for line in prompts.splitlines() if line.strip()]
if not lines:
return ("",)
return (random.choice(lines),)
class EndlessNode_RandomPromptMultiPicker:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"prompts": ("STRING", {
"multiline": True,
"default": "Line 1\nLine 2\nLine 3\nLine 4"
}),
"num_to_pick": ("INT", {
"default": 2,
"min": 1,
"max": 100,
}),
"allow_duplicates": ("BOOLEAN", {
"default": False
}),
"delimiter": ("STRING", {
"default": "\n"
}),
"seed": ("INT", {
"default": 0,
"min": 0,
"max": 2**32 - 1
}),
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("selected_prompts",)
FUNCTION = "pick_multiple"
CATEGORY = "Endless 🌊✨/Randomizers"
def pick_multiple(self, prompts, num_to_pick, allow_duplicates, delimiter, seed):
# Use the seed to ensure reproducible randomness
random.seed(seed)
lines = [line.strip() for line in prompts.splitlines() if line.strip()]
if not lines:
return ("",)
if allow_duplicates:
picks = random.choices(lines, k=num_to_pick)
else:
picks = random.sample(lines, k=min(num_to_pick, len(lines)))
return (delimiter.join(picks),)
# Optional: Auto-seed generator node
class EndlessNode_AutoSeed:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {},
"optional": {
"base_seed": ("INT", {
"default": 0,
"min": 0,
"max": 2**32 - 1
}),
}
}
RETURN_TYPES = ("INT",)
RETURN_NAMES = ("seed",)
FUNCTION = "generate_seed"
CATEGORY = "Endless 🌊✨/Randomizers"
def generate_seed(self, base_seed=0):
# Generate a new seed based on current time and base seed
current_time = int(time.time() * 1000000) # microseconds for more variation
new_seed = (base_seed + current_time) % (2**32 - 1)
return (new_seed,)