New Node
This commit is contained in:
+4
-1
@@ -30,6 +30,7 @@ from .classes.DATASET_LoadImage import N_CLASS_MAPPINGS as LoadImageMappings, N
|
||||
from .classes.DATASET_SaveImage import N_CLASS_MAPPINGS as SaveImageMappings, N_DISPLAY_NAME_MAPPINGS as SaveImageNameMappings
|
||||
from .classes.DATASET_TXTFileSaverBatch import N_CLASS_MAPPINGS as TXTFileSaverBatchMappings, N_DISPLAY_NAME_MAPPINGS as TXTFileSaverBatchNameMappings
|
||||
from .classes.DATASET_OpenAIChatImageBatch import N_CLASS_MAPPINGS as OpenAIChatImageBatchMappings, N_DISPLAY_NAME_MAPPINGS as OpenAIChatImageBatchNameMappings
|
||||
from .classes.DATASET_TriggerWords import N_CLASS_MAPPINGS as TriggerWordsMappings, N_DISPLAY_NAME_MAPPINGS as TriggerWordsNameMappings
|
||||
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
NODE_CLASS_MAPPINGS.update(TXTFileSaverMappings)
|
||||
@@ -44,6 +45,7 @@ NODE_CLASS_MAPPINGS.update(LoadImageMappings)
|
||||
NODE_CLASS_MAPPINGS.update(SaveImageMappings)
|
||||
NODE_CLASS_MAPPINGS.update(TXTFileSaverBatchMappings)
|
||||
NODE_CLASS_MAPPINGS.update(OpenAIChatImageBatchMappings)
|
||||
NODE_CLASS_MAPPINGS.update(TriggerWordsMappings)
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {}
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(TXTFileSaverNameMappings)
|
||||
@@ -56,7 +58,8 @@ NODE_DISPLAY_NAME_MAPPINGS.update(OpenAIChatNameMappings)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(OpenAIChatImageNameMappings)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(LoadImageNameMappings)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(SaveImageNameMappings)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(TXTFileSaverNameMappings)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(TXTFileSaverBatchNameMappings)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(OpenAIChatImageBatchNameMappings)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(TriggerWordsNameMappings)
|
||||
|
||||
WEB_DIRECTORY = "./web"
|
||||
@@ -0,0 +1,61 @@
|
||||
def find_trigger_words(input_str, include_till_comma=False):
|
||||
parts = [part.strip() for part in input_str.split(',')]
|
||||
trigger_words = []
|
||||
for part in parts:
|
||||
words = part.split()
|
||||
for word in words:
|
||||
if any(char.isdigit() for char in word):
|
||||
if include_till_comma:
|
||||
trigger_words.append(part)
|
||||
else:
|
||||
trigger_words.append(word)
|
||||
|
||||
return ', '.join(trigger_words)
|
||||
|
||||
class DATASET_TriggerWords:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"content": ("STRING",{"forceInput": True}),
|
||||
"search": (['trigger_word_only','trigger_word_phrase'],),
|
||||
},
|
||||
}
|
||||
|
||||
INPUT_IS_LIST = True
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("Words",)
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
FUNCTION = "FindIT"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
CATEGORY = "🔶DATASET🔶"
|
||||
|
||||
def FindIT(self, content, search):
|
||||
try:
|
||||
|
||||
search = search[0]
|
||||
words = []
|
||||
|
||||
for sentence in content:
|
||||
if search == "trigger_word_only":
|
||||
words.append(find_trigger_words(sentence, False))
|
||||
elif search == "trigger_word_phrase":
|
||||
words.append(find_trigger_words(sentence, True))
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error saving: {e}")
|
||||
|
||||
return (words,)
|
||||
|
||||
N_CLASS_MAPPINGS = {
|
||||
"DATASET_TriggerWords": DATASET_TriggerWords,
|
||||
}
|
||||
|
||||
N_DISPLAY_NAME_MAPPINGS = {
|
||||
"DATASET_TriggerWords": "DATASET_TriggerWords",
|
||||
}
|
||||
Reference in New Issue
Block a user