mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-26 08:38:15 +00:00
WIP: sync with tasks
This commit is contained in:
@@ -409,18 +409,19 @@ class Crew(BaseModel):
|
|||||||
futures: List[Tuple[Task, Future[TaskOutput]]] = []
|
futures: List[Tuple[Task, Future[TaskOutput]]] = []
|
||||||
|
|
||||||
for i, task in enumerate(self.tasks):
|
for i, task in enumerate(self.tasks):
|
||||||
if isinstance(task, ConditionalTask):
|
# if isinstance(task, ConditionalTask):
|
||||||
# print("task_outputs", task_outputs)
|
# # print("task_outputs", task_outputs)
|
||||||
previous_output = task_outputs[-1].result() if task_outputs else None
|
# previous_output = task_outputs[-1] if task_outputs else None
|
||||||
# print("previous_output type", type(previous_output))
|
# print("previous_output", previous_output)
|
||||||
if previous_output is not None:
|
# # print("previous_output type", type(previous_output))
|
||||||
if not task.should_execute(previous_output):
|
# if previous_output is not None:
|
||||||
self._logger.log(
|
# if not task.should_execute(previous_output):
|
||||||
"info",
|
# self._logger.log(
|
||||||
f"Skipping conditional task: {task.description}",
|
# "info",
|
||||||
color="yellow",
|
# f"Skipping conditional task: {task.description}",
|
||||||
)
|
# color="yellow",
|
||||||
continue
|
# )
|
||||||
|
# continue
|
||||||
if task.agent.allow_delegation: # type: ignore # Item "None" of "Agent | None" has no attribute "allow_delegation"
|
if task.agent.allow_delegation: # type: ignore # Item "None" of "Agent | None" has no attribute "allow_delegation"
|
||||||
agents_for_delegation = [
|
agents_for_delegation = [
|
||||||
agent for agent in self.agents if agent != task.agent
|
agent for agent in self.agents if agent != task.agent
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, List, Union
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ class CrewOutput(BaseModel):
|
|||||||
# TODO: Ask @joao what is the desired behavior here
|
# TODO: Ask @joao what is the desired behavior here
|
||||||
def result(
|
def result(
|
||||||
self,
|
self,
|
||||||
) -> List[str | BaseModel | Dict[str, Any]]]:
|
) -> List[str | BaseModel | Dict[str, Any]]:
|
||||||
"""Return the result of the task based on the available output."""
|
"""Return the result of the task based on the available output."""
|
||||||
results = [output.result() for output in self.output]
|
results = [output.result() for output in self.output]
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -224,7 +224,6 @@ class Task(BaseModel):
|
|||||||
tools=tools,
|
tools=tools,
|
||||||
)
|
)
|
||||||
exported_output = self._export_output(result)
|
exported_output = self._export_output(result)
|
||||||
print("exported_output", exported_output["pydantic"])
|
|
||||||
|
|
||||||
task_output = TaskOutput(
|
task_output = TaskOutput(
|
||||||
description=self.description,
|
description=self.description,
|
||||||
@@ -233,7 +232,6 @@ class Task(BaseModel):
|
|||||||
json_output=exported_output["json"],
|
json_output=exported_output["json"],
|
||||||
agent=agent.role,
|
agent=agent.role,
|
||||||
)
|
)
|
||||||
print("task_output", task_output)
|
|
||||||
self.output = task_output
|
self.output = task_output
|
||||||
|
|
||||||
if self.callback:
|
if self.callback:
|
||||||
@@ -313,8 +311,8 @@ class Task(BaseModel):
|
|||||||
self, result: str
|
self, result: str
|
||||||
) -> Dict[str, Union[BaseModel, Dict[str, Any]]]:
|
) -> Dict[str, Union[BaseModel, Dict[str, Any]]]:
|
||||||
output = {
|
output = {
|
||||||
"pydantic": self.output_pydantic() if self.output_pydantic else None,
|
"pydantic": None,
|
||||||
"json": {},
|
"json": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.output_pydantic or self.output_json:
|
if self.output_pydantic or self.output_json:
|
||||||
|
|||||||
Reference in New Issue
Block a user