Skip to content

Commit b042818

Browse files
authored
Add files via upload
1 parent d0cd04f commit b042818

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+101219
-106
lines changed

IFDisplayOmniNode.py

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

IFDisplayTextNode.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import sys
2+
import logging
3+
from typing import Optional
4+
5+
# Initialize logger
6+
logger = logging.getLogger(__name__)
7+
8+
class IFDisplayText:
9+
def __init__(self):
10+
self.type = "output"
11+
12+
@classmethod
13+
def INPUT_TYPES(cls):
14+
return {
15+
"required": {
16+
"text": ("STRING", {"forceInput": True}),
17+
"select": ("INT", {
18+
"default": 0,
19+
"min": 0,
20+
"max": sys.maxsize, # No practical upper limit
21+
"step": 1,
22+
"tooltip": "Select which line to output (cycles through available lines)"
23+
}),
24+
},
25+
"hidden": {},
26+
}
27+
28+
RETURN_TYPES = ("STRING", "STRING", "INT", "STRING")
29+
RETURN_NAMES = ("text", "text_list", "count", "selected")
30+
OUTPUT_IS_LIST = (False, True, False, False)
31+
FUNCTION = "display_text"
32+
OUTPUT_NODE = True
33+
CATEGORY = "ImpactFrames💥🎞️"
34+
35+
def display_text(self, text: Optional[str], select):
36+
if text is None:
37+
logger.error("Received None for text input in display_text.")
38+
return "" # Or handle appropriately
39+
40+
print("==================")
41+
print("IF_AI_tool_output:")
42+
print("==================")
43+
print(text)
44+
45+
# Split text into lines and filter out empty lines
46+
text_list = [line.strip() for line in text.split('\n') if line.strip()]
47+
count = len(text_list)
48+
49+
# Select line using modulo to handle cycling
50+
if count == 0:
51+
selected = text # If no valid lines, return original text
52+
else:
53+
selected = text_list[select % count]
54+
55+
# Return both UI update and the multiple outputs
56+
return {
57+
"ui": {"string": [text]},
58+
"result": (
59+
text, # complete text
60+
text_list, # list of individual lines as separate string outputs
61+
count, # number of lines
62+
selected # selected line based on select input
63+
)
64+
}
65+
66+
NODE_CLASS_MAPPINGS = {"IF_DisplayText": IFDisplayText}
67+
NODE_DISPLAY_NAME_MAPPINGS = {"IF_DisplayText": "IF Display Text📟"}
68+
69+

0 commit comments

Comments
 (0)