From 6329d724e31388e961145c69f68848b23b77ece1 Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Sun, 5 Nov 2023 23:45:16 -0300 Subject: [PATCH] implementing sequential process --- crewai/crew.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/crewai/crew.py b/crewai/crew.py index 5de7ddd00..ad542808a 100644 --- a/crewai/crew.py +++ b/crewai/crew.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Any from pydantic.v1 import BaseModel, Field from .process import Process @@ -11,9 +11,12 @@ class Crew(BaseModel): their tasks. """ goal: str = Field(description="Objective of the crew being created.") - process: Process = Field(description="Process that the crew will follow.") tasks: List[Task] = Field(description="List of tasks") agents: List[Agent] = Field(description="List of agents in this crew.") + process: Process = Field( + description="Process that the crew will follow.", + default=Process.sequential + ) def kickoff(self) -> str: """ @@ -21,19 +24,18 @@ class Crew(BaseModel): Returns: output (List[str]): Output of the crew for each task. """ - # if self.process == Process.consensual: - + if self.process == Process.sequential: + return self.__sequential_loop() return "Crew is executing task" - def __consensual_loop(self) -> str: + def __sequential_loop(self) -> str: """ - Loop that executes the consensual process. + Loop that executes the sequential process. Returns: output (str): Output of the crew. """ + task_outcome = None + for task in self.tasks: + task_outcome = task.execute(task_outcome) - # The group of agents need to decide which agent will execute each task - # in the self.task list. This is done by a voting process between all the - # agents in self.agents. The agent with the most votes will execute the - # task. - pass \ No newline at end of file + return task_outcome \ No newline at end of file