implementing sequential process

This commit is contained in:
Joao Moura
2023-11-05 23:45:16 -03:00
parent 48aa2a8750
commit 6329d724e3

View File

@@ -1,4 +1,4 @@
from typing import List from typing import List, Any
from pydantic.v1 import BaseModel, Field from pydantic.v1 import BaseModel, Field
from .process import Process from .process import Process
@@ -11,9 +11,12 @@ class Crew(BaseModel):
their tasks. their tasks.
""" """
goal: str = Field(description="Objective of the crew being created.") 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") tasks: List[Task] = Field(description="List of tasks")
agents: List[Agent] = Field(description="List of agents in this crew.") 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: def kickoff(self) -> str:
""" """
@@ -21,19 +24,18 @@ class Crew(BaseModel):
Returns: Returns:
output (List[str]): Output of the crew for each task. 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" 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: Returns:
output (str): Output of the crew. 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 return task_outcome
# 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