add new output nodes

This commit is contained in:
wl-zhao
2024-10-22 19:47:04 +08:00
parent b3042fdf6f
commit fc1f9afbcd
2 changed files with 74 additions and 1 deletions
-1
View File
@@ -80,7 +80,6 @@ class ShellAgentSaveVideoVHS:
preview_image = os.path.relpath(preview_image)
video_path = os.path.relpath(video_path)
results = {"ui": {"image": [preview_image], "video": [video_path]}}
print(results)
return results
+74
View File
@@ -0,0 +1,74 @@
json_type_mapipng = {
"text": "string",
"float": "number",
"integer": "integer"
}
class ShellAgentOutputText:
TYPE_STR = "text"
@classmethod
def INPUT_TYPES(s):
return {
"required": {
s.TYPE_STR: ("STRING", {"tooltip": f"The {s.TYPE_STR} to output."}),
"output_name": ("STRING", {"multiline": False, "default": f"output_{s.TYPE_STR}"},),
},
}
RETURN_TYPES = ()
FUNCTION = "output_var"
OUTPUT_NODE = True
CATEGORY = "shellagent"
DESCRIPTION = "output the text"
@classmethod
def validate(cls, **kwargs):
schema = {
"title": kwargs["output_name"],
"type": json_type_mapipng[cls.TYPE_STR]
}
return schema
def output_var(self, **kwargs):
results = {"ui": {"output": [kwargs[self.TYPE_STR]]}}
return results
class ShellAgentOutputFloat(ShellAgentOutputText):
TYPE_STR = "float"
DESCRIPTION = "output the float"
@classmethod
def INPUT_TYPES(s):
return {
"required": {
s.TYPE_STR: ("STRING", {"tooltip": f"The {s.TYPE_STR} to output."}),
"output_name": ("STRING", {"multiline": False, "default": f"output_{s.TYPE_STR}"},),
},
}
class ShellAgentOutputInteger(ShellAgentOutputText):
TYPE_STR = "integer"
DESCRIPTION = "output the integer"
@classmethod
def INPUT_TYPES(s):
return {
"required": {
s.TYPE_STR: ("STRING", {"tooltip": f"The {s.TYPE_STR} to output."}),
"output_name": ("STRING", {"multiline": False, "default": f"output_{s.TYPE_STR}"},),
},
}
NODE_CLASS_MAPPINGS = {
"ShellAgentPluginOutputText": ShellAgentOutputText,
"ShellAgentPluginOutputFloat": ShellAgentOutputFloat,
"ShellAgentPluginOutputInteger": ShellAgentOutputInteger
}
NODE_DISPLAY_NAME_MAPPINGS = {
"ShellAgentPluginOutputText": "Output Text (ShellAgent Plugin)",
"ShellAgentPluginOutputFloat": "Output Float (ShellAgent Plugin)",
"ShellAgentPluginOutputInteger": "Output Integer (ShellAgent Plugin)",
}