Skip to content

Commit ec0414e

Browse files
authored
Add files via upload
1 parent b2b3580 commit ec0414e

Some content is hidden

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

69 files changed

+11665
-2326
lines changed

IFChatPromptNode.py

Lines changed: 1121 additions & 382 deletions
Large diffs are not rendered by default.

IFDisplayTextNode.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,59 @@
1+
import sys
2+
13
class IFDisplayText:
24
def __init__(self):
35
self.type = "output"
46

57
@classmethod
68
def INPUT_TYPES(cls):
7-
89
return {
910
"required": {
10-
"text": ("STRING", {"forceInput": True}),
11-
},
11+
"text": ("STRING", {"forceInput": True}),
12+
"select": ("INT", {
13+
"default": 0,
14+
"min": 0,
15+
"max": sys.maxsize, # No practical upper limit
16+
"step": 1,
17+
"tooltip": "Select which line to output (cycles through available lines)"
18+
}),
19+
},
1220
"hidden": {},
13-
}
21+
}
1422

15-
RETURN_TYPES = ("STRING",)
23+
RETURN_TYPES = ("STRING", "STRING", "INT", "STRING")
24+
RETURN_NAMES = ("text", "text_list", "count", "selected")
25+
OUTPUT_IS_LIST = (False, True, False, False)
1626
FUNCTION = "display_text"
1727
OUTPUT_NODE = True
1828
CATEGORY = "ImpactFrames💥🎞️"
1929

20-
def display_text(self, text):
30+
def display_text(self, text, select):
2131
print("==================")
2232
print("IF_AI_tool_output:")
2333
print("==================")
2434
print(text)
25-
return {"ui": {"string": [text,]}, "result": (text,)}
26-
35+
36+
# Split text into lines and filter out empty lines
37+
text_list = [line.strip() for line in text.split('\n') if line.strip()]
38+
count = len(text_list)
39+
40+
# Select line using modulo to handle cycling
41+
if count == 0:
42+
selected = text # If no valid lines, return original text
43+
else:
44+
selected = text_list[select % count]
45+
46+
# Return both UI update and the multiple outputs
47+
return {
48+
"ui": {"string": [text]},
49+
"result": (
50+
text, # complete text
51+
text_list, # list of individual lines as separate string outputs
52+
count, # number of lines
53+
selected # selected line based on select input
54+
)
55+
}
56+
2757
NODE_CLASS_MAPPINGS = {"IF_DisplayText": IFDisplayText}
2858
NODE_DISPLAY_NAME_MAPPINGS = {"IF_DisplayText": "IF Display Text📟"}
2959

IFImagePromptNode.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,31 @@
1010
import tempfile
1111
from torchvision.transforms.functional import to_pil_image
1212
import folder_paths
13-
from server import PromptServer
14-
from aiohttp import web
15-
16-
@PromptServer.instance.routes.post("/IF_ImagePrompt/get_models")
17-
async def get_models_endpoint(request):
18-
data = await request.json()
19-
engine = data.get("engine")
20-
base_ip = data.get("base_ip")
21-
port = data.get("port")
22-
23-
node = IFImagePrompt()
24-
models = node.get_models(engine, base_ip, port)
25-
return web.json_response(models)
13+
import sys
14+
15+
# Add the ComfyUI directory to the Python path
16+
comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
17+
sys.path.insert(0, comfy_path)
18+
19+
try:
20+
from server import PromptServer
21+
from aiohttp import web
22+
23+
@PromptServer.instance.routes.post("/IF_ImagePrompt/get_models")
24+
async def get_models_endpoint(request):
25+
data = await request.json()
26+
engine = data.get("engine")
27+
base_ip = data.get("base_ip")
28+
port = data.get("port")
29+
30+
node = IFImagePrompt()
31+
models = node.get_models(engine, base_ip, port)
32+
return web.json_response(models)
33+
except AttributeError:
34+
print("PromptServer.instance not available. Skipping route decoration for IF_ImagePrompt.")
35+
async def get_models_endpoint(request):
36+
# Fallback implementation
37+
return web.json_response({"error": "PromptServer.instance not available"})
2638

2739
class IFImagePrompt:
2840

IFJoinTextNode.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
class IFJoinText:
2+
@classmethod
3+
def INPUT_TYPES(cls):
4+
return {
5+
"required": {
6+
"separator": ("STRING", {
7+
"multiline": False,
8+
"default": " ",
9+
"placeholder": "Text to insert between joined strings"
10+
}),
11+
},
12+
"optional": {
13+
"text1": ("STRING", {
14+
"multiline": False,
15+
"default": "",
16+
"forceInput": True,
17+
"placeholder": "First text input"
18+
}),
19+
"text2": ("STRING", {
20+
"multiline": False,
21+
"default": "",
22+
"forceInput": True,
23+
"placeholder": "Second text input"
24+
}),
25+
"text3": ("STRING", {
26+
"multiline": False,
27+
"default": "",
28+
"forceInput": True,
29+
"placeholder": "Third text input"
30+
}),
31+
"text4": ("STRING", {
32+
"multiline": False,
33+
"default": "",
34+
"forceInput": True,
35+
"placeholder": "Fourth text input"
36+
}),
37+
},
38+
}
39+
40+
RETURN_TYPES = ("STRING",)
41+
FUNCTION = "join_text"
42+
CATEGORY = "ImpactFrames💥🎞️"
43+
44+
def join_text(self, separator=" ", text1="", text2="", text3="", text4=""):
45+
# Collect all non-empty text inputs
46+
texts = [t for t in [text1, text2, text3, text4] if t.strip()]
47+
48+
# Join texts with separator
49+
result = separator.join(texts)
50+
51+
# Print for debugging
52+
print("==================")
53+
print("IF_JoinText output:")
54+
print("==================")
55+
print(result)
56+
57+
return (result,)
58+
59+
NODE_CLASS_MAPPINGS = {
60+
"IF_JoinText": IFJoinText
61+
}
62+
63+
NODE_DISPLAY_NAME_MAPPINGS = {
64+
"IF_JoinText": "IF Join Text 📝"
65+
}

0 commit comments

Comments
 (0)