mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-07-28 08:46:35 +00:00
V3: PreviewAny node
This commit is contained in:
parent
c3334ae813
commit
106bc9b32a
47
comfy_extras/v3/nodes_preview_any.py
Normal file
47
comfy_extras/v3/nodes_preview_any.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
from comfy_api.v3 import io, ui
|
||||||
|
|
||||||
|
|
||||||
|
class PreviewAny(io.ComfyNodeV3):
|
||||||
|
"""Originally implement from https://github.com/rgthree/rgthree-comfy/blob/main/py/display_any.py
|
||||||
|
|
||||||
|
upstream requested in https://github.com/Kosinkadink/rfcs/blob/main/rfcs/0000-corenodes.md#preview-nodes"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def define_schema(cls):
|
||||||
|
return io.SchemaV3(
|
||||||
|
node_id="PreviewAny_V3", # frontend expects "PreviewAny" to work
|
||||||
|
display_name="Preview Any _V3", # frontend ignores "display_name" for this node
|
||||||
|
description="Preview any type of data by converting it to a readable text format.",
|
||||||
|
category="utils",
|
||||||
|
inputs=[
|
||||||
|
io.AnyType.Input("source"), # TODO: does not work currently, as `io.AnyType` does not define __ne__
|
||||||
|
],
|
||||||
|
is_output_node=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def execute(cls, source=None) -> io.NodeOutput:
|
||||||
|
value = "None"
|
||||||
|
if isinstance(source, str):
|
||||||
|
value = source
|
||||||
|
elif isinstance(source, (int, float, bool)):
|
||||||
|
value = str(source)
|
||||||
|
elif source is not None:
|
||||||
|
try:
|
||||||
|
value = json.dumps(source)
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
value = str(source)
|
||||||
|
except Exception:
|
||||||
|
value = "source exists, but could not be serialized."
|
||||||
|
|
||||||
|
return io.NodeOutput(ui=ui.PreviewText(value))
|
||||||
|
|
||||||
|
|
||||||
|
NODES_LIST: list[type[io.ComfyNodeV3]] = [
|
||||||
|
PreviewAny,
|
||||||
|
]
|
1
nodes.py
1
nodes.py
@ -2303,6 +2303,7 @@ def init_builtin_extra_nodes():
|
|||||||
"v3/nodes_controlnet.py",
|
"v3/nodes_controlnet.py",
|
||||||
"v3/nodes_images.py",
|
"v3/nodes_images.py",
|
||||||
"v3/nodes_mask.py",
|
"v3/nodes_mask.py",
|
||||||
|
"v3/nodes_preview_any.py",
|
||||||
"v3/nodes_primitive.py",
|
"v3/nodes_primitive.py",
|
||||||
"v3/nodes_webcam.py",
|
"v3/nodes_webcam.py",
|
||||||
"v3/nodes_stable_cascade.py",
|
"v3/nodes_stable_cascade.py",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user