Refactoring

This commit is contained in:
nkchocoai
2024-01-27 14:04:53 +09:00
parent a3db60d679
commit de907cceb2
6 changed files with 55 additions and 53 deletions
+4 -1
View File
@@ -1,4 +1,7 @@
from .py.node import *
from .py.node.const import *
from .py.node.format import *
from .py.node.preset import *
NODE_CLASS_MAPPINGS = {
"PromptUtilitiesFormatString": PromptUtilitiesFormatString,
View File
+2
View File
@@ -0,0 +1,2 @@
class BaseNode:
CATEGORY = "PromptUtilities"
+28
View File
@@ -0,0 +1,28 @@
from .base import BaseNode
class PromptUtilitiesConstStringBase(BaseNode):
RETURN_TYPES = ("STRING",)
FUNCTION = "get_string"
def get_string(self, string):
return (string,)
class PromptUtilitiesConstString(PromptUtilitiesConstStringBase):
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": ("STRING", {"default": "", "multiline": False})
}
}
class PromptUtilitiesConstStringMultiLine(PromptUtilitiesConstStringBase):
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": ("STRING", {"default": "", "multiline": True})
}
}
+2 -52
View File
@@ -1,37 +1,4 @@
import folder_paths
from .preset import PresetManager
class BaseNode:
CATEGORY = "PromptUtilities"
class PromptUtilitiesConstStringBase(BaseNode):
RETURN_TYPES = ("STRING",)
FUNCTION = "get_string"
def get_string(self, string):
return (string,)
class PromptUtilitiesConstString(PromptUtilitiesConstStringBase):
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": ("STRING", {"default": "", "multiline": False})
}
}
class PromptUtilitiesConstStringMultiLine(PromptUtilitiesConstStringBase):
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": ("STRING", {"default": "", "multiline": True})
}
}
from .base import BaseNode
class PromptUtilitiesFormatString(BaseNode):
@@ -81,21 +48,4 @@ class PromptUtilitiesJoinStringList(BaseNode):
print(kwargs)
print(kwargs.values())
result = separator.join(kwargs.values())
return (result,)
class PromptUtilitiesLoadPreset(BaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"preset": (list(PresetManager.get_presets().keys()), ),
}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "load_preset"
def load_preset(self, preset):
prompt = PresetManager.get_prompt(preset)
return (prompt,)
return (result,)
+19
View File
@@ -0,0 +1,19 @@
from .base import BaseNode
from ..preset import PresetManager
class PromptUtilitiesLoadPreset(BaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"preset": (list(PresetManager.get_presets().keys()), ),
}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "load_preset"
def load_preset(self, preset):
prompt = PresetManager.get_prompt(preset)
return (prompt,)