-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathIFDisplayOmniNode.py
65 lines (55 loc) · 2.67 KB
/
IFDisplayOmniNode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class IFDisplayOmni:
@classmethod
def INPUT_TYPES(s):
return {
"required": {},
"optional": {"omni_input": ("OMNI", {})},
"hidden": {"unique_id": "UNIQUE_ID", "extra_pnginfo": "EXTRA_PNGINFO"},
}
RETURN_TYPES = ("OMOST_CANVAS_CONDITIONING", "STRING")
RETURN_NAMES = ("canvas_conditioning", "text_output")
INPUT_IS_LIST = True
OUTPUT_NODE = True
FUNCTION = "display_omni"
CATEGORY = "ImpactFrames💥🎞️/IF_tools"
def display_omni(self, unique_id=None, extra_pnginfo=None, **kwargs):
values = []
canvas_conditioning = None
text_output = ""
if "omni_input" in kwargs:
for val in kwargs['omni_input']:
try:
if isinstance(val, dict) and "conditionings" in val:
# Handle batched canvas conditionings
canvas_conditioning = val["conditionings"]
# The responses will come from IF_DisplayText
text_output = val.get("error", "")
values.append(text_output)
elif isinstance(val, list) and all(isinstance(item, dict) for item in val):
# Direct canvas conditioning list
canvas_conditioning = val
values.append(str(val))
elif isinstance(val, str):
values.append(val)
text_output = val
else:
json_val = json.dumps(val)
values.append(str(json_val))
text_output = str(json_val)
except Exception as e:
print(f"Error processing omni input: {str(e)}")
values.append(str(val))
text_output = str(val)
# Update workflow info if available
if unique_id is not None and extra_pnginfo is not None:
if isinstance(extra_pnginfo, list) and len(extra_pnginfo) > 0:
extra_pnginfo = extra_pnginfo[0]
if isinstance(extra_pnginfo, dict) and "workflow" in extra_pnginfo:
workflow = extra_pnginfo["workflow"]
node = next((x for x in workflow["nodes"] if str(x["id"]) == unique_id), None)
if node:
node["widgets_values"] = [values]
return {
"ui": {"text": values},
"result": (canvas_conditioning, text_output)
}