Initial working version
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
A vast Sahara desert, endless dunes stretching under a blistering sun.
|
||||
An ancient Roman amphitheater, weathered stone, and whispers of history.
|
||||
A bustling Tokyo intersection, neon lights flashing amidst a sea of people.
|
||||
A serene Swiss lake, crystal-clear waters reflecting towering snow-capped peaks.
|
||||
A quiet New Zealand meadow, sheep grazing beneath rolling green hills.
|
||||
A vibrant Marrakech market, spice-scented air filled with colorful textiles.
|
||||
A remote Antarctic tundra, icy winds sweeping across barren white plains.
|
||||
A cozy Parisian café, street musicians playing beneath twinkling cafe lights.
|
||||
A misty Irish cliff, emerald waves crashing against jagged stone edges.
|
||||
A lively Rio de Janeiro beach, golden sands and rhythmic samba.
|
||||
A fog-covered San Francisco bridge, the city disappearing into misty air.
|
||||
A tranquil Bali temple, incense drifting through lush tropical gardens.
|
||||
A sprawling Kenyan savannah, elephants grazing beneath vast open skies.
|
||||
A secluded Icelandic hot spring, steam rising amidst snowy volcanic rocks.
|
||||
A bustling Cairo street, ancient pyramids looming over a sea of people.
|
||||
A quiet Kyoto garden, delicate cherry blossoms drifting on still waters.
|
||||
A remote Pacific island, turquoise waters surrounding lush palm-fringed shores.
|
||||
A golden Egyptian desert, camels trekking beneath an endless blue sky.
|
||||
A busy London street, red buses passing by historic stone buildings.
|
||||
A vibrant Sydney harbor, sun reflecting off iconic sails and clear water.
|
||||
A sprawling Australian outback, red dirt and endless, dusty horizons.
|
||||
A foggy Scottish moor, heather stretching beneath a brooding sky.
|
||||
A lively Istanbul bazaar, colorful lanterns hanging in the bustling aisles.
|
||||
A calm Norwegian fjord, steep cliffs towering above crystal-clear waters.
|
||||
A dense Amazon rainforest, sunlight filtering through towering emerald canopies.
|
||||
A quiet Greek village, whitewashed houses set against a blue sea.
|
||||
A narrow Venice alleyway, winding canals reflecting sunlight off old stone.
|
||||
A remote Mongolian steppe, wild horses grazing beneath an endless sky.
|
||||
A steep Himalayan pass, snow-covered peaks rising high above the clouds.
|
||||
A tranquil Costa Rican jungle, birds singing amidst lush greenery.
|
||||
A snowy Canadian Rockies, jagged peaks rising against a crisp, clear sky.
|
||||
A crowded Hong Kong street market, neon signs illuminating food stalls.
|
||||
A peaceful Tahitian lagoon, coral reefs surrounding small, sun-drenched islands.
|
||||
A weathered Alaskan fishing town, old wooden shacks by the water.
|
||||
A historic Cairo street, merchants selling spices beneath towering minarets.
|
||||
A remote Russian Siberian forest, towering pines stretching towards the horizon.
|
||||
A secluded Finnish cabin, smoke rising from the chimney, nestled in snow.
|
||||
A bustling Paris street, cafés lining the sidewalk beneath ancient stone buildings.
|
||||
A quiet Icelandic village, colorful houses standing against the backdrop of volcanoes.
|
||||
A misty Colombian coffee farm, rich green slopes stretching into the distance.
|
||||
A vibrant Mexican market, handmade crafts and fresh produce stacked high.
|
||||
A high-altitude Peruvian mountain village, terraced fields rising to the sky.
|
||||
A lonely Swedish lighthouse, its beam cutting through the endless winter night.
|
||||
A tropical Thai island, white sands and clear turquoise water stretching endlessly.
|
||||
A distant New York skyline, skyscrapers reaching into a golden evening sky.
|
||||
A quiet Sri Lankan beach, fishing boats lined up on the shore.
|
||||
A rugged Scottish castle, perched high on a hill, overlooking the sea.
|
||||
A remote Greenland ice sheet, vast and empty, stretching beyond sight.
|
||||
A historical London square, statues and fountains amidst the bustle of life.
|
||||
A bustling Mexican beach, tourists lounging beneath brightly colored umbrellas.
|
||||
A peaceful Kyoto street, ancient temples standing quietly beneath cherry blossoms.
|
||||
A remote Bhutanese monastery, perched high above the valley, overlooking the hills.
|
||||
A busy Mumbai street, tuk-tuks weaving between brightly colored storefronts.
|
||||
A serene Swedish archipelago, countless small islands dotted in the calm waters.
|
||||
A quiet Malaysian rainforest, towering trees creating a canopy of green.
|
||||
A colorful Salvador street, colonial buildings painted in shades of pastel.
|
||||
A golden Moroccan desert, camels slowly trekking beneath a setting sun.
|
||||
A quiet Tibetan plateau, prayer flags fluttering in the brisk mountain wind.
|
||||
A lively Buenos Aires café, patrons sipping espresso beneath umbrellas on the sidewalk.
|
||||
A vibrant Jakarta street, motorcycles speeding through crowded, narrow lanes.
|
||||
A serene Vietnamese rice terrace, the sun rising over the green fields.
|
||||
A bustling Singapore marina, sleek yachts docked beside modern glass skyscrapers.
|
||||
A narrow Czech alley, medieval buildings lined with antique shops and cafés.
|
||||
A charming Amsterdam canal, colorful houseboats swaying gently in the breeze.
|
||||
A vibrant Buenos Aires street, tango dancers twirling on the sidewalk.
|
||||
A remote Hawaiian beach, waves crashing against black volcanic rocks.
|
||||
A quiet Dubrovnik street, cobblestone alleys leading to ancient stone walls.
|
||||
A dense Moroccan souk, merchants calling out beneath rows of colorful scarves.
|
||||
A remote Arctic tundra, polar bears wandering beneath a pale blue sky.
|
||||
A vibrant Barcelona park, children playing beneath a canopy of trees.
|
||||
A foggy Tokyo harbor, ferries crossing beneath a giant steel bridge.
|
||||
A crumbling ancient temple in Angkor Wat, vines weaving through stone ruins.
|
||||
A quiet New England town, white clapboard houses dotting the rolling hills.
|
||||
A distant Andes mountain range, snow-capped peaks towering above a calm valley.
|
||||
A dusty Arizona desert, cacti stretching towards a blazing orange sunset.
|
||||
A serene Vietnamese fishing village, wooden boats anchored in calm waters.
|
||||
A majestic Turkish palace, ornate arches and columns standing against the skyline.
|
||||
A peaceful Finnish lake, canoes gliding silently across the still water.
|
||||
A bustling Cairo square, crowded streets and the hum of daily life.
|
||||
A remote Japanese island, lush forests and tranquil beaches hidden away.
|
||||
A sunny Santorini terrace, whitewashed buildings overlooking the deep blue sea.
|
||||
A lonely Atacama desert, vast stretches of salt flats and red rocks.
|
||||
A colorful Mexican town square, brightly painted buildings surrounding a stone fountain.
|
||||
A snowy Swedish ski resort, towering pines dusted with fresh powder.
|
||||
A tranquil Swiss alpine village, wooden chalets nestled in green valleys.
|
||||
A busy Seoul street, neon signs illuminating shops full of street food.
|
||||
A vast Chilean Patagonia, glaciers carving deep blue lakes beneath jagged peaks.
|
||||
A misty New Zealand fjord, waterfalls cascading into the tranquil water.
|
||||
A vibrant Bangkok street, tuk-tuks whizzing past street vendors and neon lights.
|
||||
A quiet Canadian woodland, towering pines and crystal-clear lakes.
|
||||
A bustling Seoul market, fresh seafood and vibrant textiles filling the stalls.
|
||||
A historic Rome square, fountains and cobblestone streets alive with tourists.
|
||||
A peaceful Greek harbor, small fishing boats swaying gently beneath the stars.
|
||||
A dramatic Icelandic waterfall, water crashing down into a misty canyon.
|
||||
A quiet Australian beach, long stretches of white sand meeting turquoise waters.
|
||||
A lively New Orleans street, jazz music spilling from open windows.
|
||||
A remote Alaskan glacier, icebergs floating in a calm, pristine bay.
|
||||
A crowded Shanghai street, modern skyscrapers towering over bustling sidewalks.
|
||||
A tranquil Scottish loch, mist rising over still waters surrounded by mountains.
|
||||
@@ -0,0 +1,65 @@
|
||||
import random
|
||||
from typing import List
|
||||
import comfy.model_management as model_management
|
||||
|
||||
class TT_StoryCombiner:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"text1": ("STRING", {"multiline": True}),
|
||||
"text2": ("STRING", {"multiline": True}),
|
||||
"text3": ("STRING", {"multiline": True}),
|
||||
"text4": ("STRING", {"multiline": True}),
|
||||
"text5": ("STRING", {"multiline": True}),
|
||||
"text6": ("STRING", {"multiline": True}),
|
||||
"text7": ("STRING", {"multiline": True}),
|
||||
"text8": ("STRING", {"multiline": True}),
|
||||
"text9": ("STRING", {"multiline": True}),
|
||||
"separator": ("STRING", {"default": ". "}),
|
||||
"seed": ("INT", {"default": 0}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "process"
|
||||
CATEGORY = "TT_TextTools"
|
||||
|
||||
def process(self, text1: str, text2: str, text3: str, text4: str, text5: str, text6: str, text7: str, text8: str, text9: str, separator: str, seed: int) -> List[str]:
|
||||
random.seed(seed)
|
||||
|
||||
def get_random_line(text):
|
||||
lines = [line.strip() for line in text.split("\n") if line.strip()]
|
||||
return random.choice(lines) if lines else ""
|
||||
|
||||
selected_lines = [
|
||||
get_random_line(text1),
|
||||
get_random_line(text2),
|
||||
get_random_line(text3),
|
||||
get_random_line(text4),
|
||||
get_random_line(text5),
|
||||
get_random_line(text6),
|
||||
get_random_line(text7),
|
||||
get_random_line(text8),
|
||||
get_random_line(text9)
|
||||
]
|
||||
|
||||
filtered_lines = [line for line in selected_lines if line]
|
||||
|
||||
result = separator.join(filtered_lines)
|
||||
|
||||
return (result,)
|
||||
|
||||
def register_nodes():
|
||||
return {"TT_StoryCombiner": TT_StoryCombiner}
|
||||
|
||||
# A dictionary that contains all nodes you want to export with their names
|
||||
# NOTE: names should be globally unique
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"TT_StoryCombiner": TT_StoryCombiner
|
||||
}
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"TT_StoryCombiner": "TT_StoryCombiner"
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import os
|
||||
import random
|
||||
from typing import List
|
||||
from nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
||||
|
||||
class TT_TextFileSelectorNode:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
"""
|
||||
Defines the input types for the node. The user only provides the 'file_path' and 'seed'.
|
||||
No 'selection' input is provided.
|
||||
"""
|
||||
file_path = os.path.join(os.path.dirname(__file__), "DefaultList.txt") # Relative path to the .txt file
|
||||
return {
|
||||
"required": {
|
||||
"seed": ("INT", {"default": 42}),
|
||||
"file_path": ("STRING", {"default": file_path}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",) # The output will be a string
|
||||
FUNCTION = "output_selection" # Function that will process the data
|
||||
CATEGORY = "TT_TextTools" # Category for organization in the UI
|
||||
|
||||
@staticmethod
|
||||
def load_options(file_path: str = "DefaultList.txt") -> List[str]:
|
||||
"""
|
||||
Loads options from a specified .txt file and forces reload on every call.
|
||||
"""
|
||||
# Check if the file exists and is not empty
|
||||
if not os.path.exists(file_path) or os.path.getsize(file_path) == 0:
|
||||
return ["No options available"] # Default message if file is empty or missing
|
||||
|
||||
# Open and read the file fresh every time
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
return [line.strip() for line in f.readlines() if line.strip()]
|
||||
|
||||
def output_selection(self, seed: int, file_path: str):
|
||||
"""
|
||||
Processes the selection and returns either a random choice from the file or a specific choice.
|
||||
"""
|
||||
options = self.load_options(file_path) # Force reload of the options from the file
|
||||
|
||||
if options == ["No options available"]:
|
||||
return ("No options available",)
|
||||
|
||||
random.seed(seed) # Set the random seed for reproducibility
|
||||
|
||||
# Return a random choice from the options
|
||||
return (random.choice(options),)
|
||||
|
||||
# Register the new node class
|
||||
NODE_CLASS_MAPPINGS["TT_TextFileSelectorNode"] = TT_TextFileSelectorNode
|
||||
NODE_DISPLAY_NAME_MAPPINGS["TT_TextFileSelectorNode"] = "Text File Selector Node" # Friendly name for UI
|
||||
@@ -0,0 +1,17 @@
|
||||
import comfy.model_management
|
||||
|
||||
class TT_TextInput:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {"text": ("STRING", {"multiline": True, "default": ""})}}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "process"
|
||||
CATEGORY = "TT_TextTools"
|
||||
|
||||
def process(self, text):
|
||||
return (text,)
|
||||
|
||||
# Register the node
|
||||
NODE_CLASS_MAPPINGS = {"TT_TextInput": TT_TextInput}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {"TT_TextInput": "TT_Text Input"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
from .TT_StoryCombiner import TT_StoryCombiner
|
||||
from .TT_TextInput import TT_TextInput
|
||||
from .TT_TextFileSelectorNode import TT_TextFileSelectorNode
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"TT_StoryCombiner": TT_StoryCombiner,
|
||||
"TT_TextInput": TT_TextInput,
|
||||
"TT_TextFileSelectorNode": TT_TextFileSelectorNode,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"TT_StoryCombiner": "TT_StoryCombiner",
|
||||
"TT_TextInput": "TT_Text Input",
|
||||
"TT_TextFileSelectorNode": "TT_TextFileSelectorNode",
|
||||
}
|
||||
Reference in New Issue
Block a user