diff --git a/agent_node.py b/agent_node.py index 9af2d65..60ece1d 100644 --- a/agent_node.py +++ b/agent_node.py @@ -11,6 +11,8 @@ class AgentNode: "role": ("STRING", {"default": ""}), "goal": ("STRING", {"default": ""}), "backstory": ("STRING", {"default": ""}), + }, + "optional": { "verbose": ("BOOL", {"default": False}), "allow_delegation": ("BOOL", {"default": False}), }, diff --git a/base_node.py b/base_node.py index ea7bb88..f50dcbe 100644 --- a/base_node.py +++ b/base_node.py @@ -1,2 +1,12 @@ class BaseNode: CATEGORY = "📎CrewAI" + + def create_list(self, **kwargs): + list = [] + + # Collect all agents from kwargs dynamically + for _k, v in kwargs.items(): + if v is not None: + list.append(v) + + return (list,) \ No newline at end of file diff --git a/crew_node.py b/crew_node.py index 01f012c..2ebe9a3 100644 --- a/crew_node.py +++ b/crew_node.py @@ -9,10 +9,12 @@ class CrewNode(BaseNode): def INPUT_TYPES(cls): return { "required": { - "agents": ("AGENT", {"default": []}), "tasks": ("TASK", {"default": []}), - "process": ("STRING", {"default": "sequential", "choices": ["sequential", "hierarchical"]}), + }, + "optional": { "topic": ("STRING", {"default": ""}), + "agents": ("AGENT", {"default": []}), + "process": ("STRING", {"default": "sequential", "choices": ["sequential", "hierarchical"]}), }, } INPUT_IS_LIST = (True, True, False, False) diff --git a/list_agent_node.py b/list_agent_node.py index 48fd639..412a38e 100644 --- a/list_agent_node.py +++ b/list_agent_node.py @@ -4,23 +4,9 @@ from .base_node import BaseNode class AgentList(BaseNode): @classmethod def INPUT_TYPES(cls): - # Generate a dictionary for up to n agents dynamically - inputs = {"required": {"agent-1": ("AGENT",)}} - # for i in range(2, 101): # Adjust the range as needed - # inputs["optional"] = inputs.get("optional", {}) - # inputs["optional"][f"agent{i}"] = ("AGENT",) - return inputs + return {"required": {"agent-1": ("AGENT",)}} OUTPUT_IS_LIST = (True,) RETURN_TYPES = ("AGENT",) FUNCTION = "create_list" - def create_list(self, **kwargs): - agents = [] - - # Collect all agents from kwargs dynamically - for key, value in kwargs.items(): - if value is not None: - agents.append(value) - - return (agents,) \ No newline at end of file diff --git a/list_task_node.py b/list_task_node.py index 5428b95..181aa20 100644 --- a/list_task_node.py +++ b/list_task_node.py @@ -1,25 +1,10 @@ from .base_node import BaseNode -from crewai import Crew, Process class TaskList(BaseNode): @classmethod def INPUT_TYPES(s): - # Generate a dictionary for up to n agents dynamically - inputs = {"required": {"task-1": ("TASK",)}} - # for i in range(2, 101): # Adjust the range as needed - # inputs["optional"] = inputs.get("optional", {}) - # inputs["optional"][f"agent{i}"] = ("AGENT",) - return inputs - + return {"required": {"task-1": ("TASK",)}} OUTPUT_IS_LIST = (True,) RETURN_TYPES = ("TASK",) - FUNCTION = "create_list" - - def create_list(self, **kwargs): - task = [] - - for k, v in kwargs.items(): - task.append(v) - - return (task, ) + FUNCTION = "create_list" \ No newline at end of file diff --git a/task_node.py b/task_node.py index 1069798..423c249 100644 --- a/task_node.py +++ b/task_node.py @@ -10,9 +10,11 @@ class TaskNode(BaseNode): return { "required": { "description": ("STRING", {"default": ""}), + }, + "optional": { "expected_output": ("STRING", {"default": ""}), "agent": ("AGENT",), - }, + } } RETURN_TYPES = ("TASK",)