Refactor code

This commit is contained in:
Luan Citta
2024-06-05 09:24:33 +01:00
parent 569a676029
commit bbd80ef50a
6 changed files with 22 additions and 35 deletions
+2
View File
@@ -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}),
},
+10
View File
@@ -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,)
+4 -2
View File
@@ -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)
+1 -15
View File
@@ -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,)
+2 -17
View File
@@ -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"
+3 -1
View File
@@ -10,9 +10,11 @@ class TaskNode(BaseNode):
return {
"required": {
"description": ("STRING", {"default": ""}),
},
"optional": {
"expected_output": ("STRING", {"default": ""}),
"agent": ("AGENT",),
},
}
}
RETURN_TYPES = ("TASK",)