mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
WIP
This commit is contained in:
@@ -459,7 +459,7 @@ class Crew(BaseModel):
|
|||||||
self._file_handler.log(
|
self._file_handler.log(
|
||||||
agent=role, task=task.description, status="started"
|
agent=role, task=task.description, status="started"
|
||||||
)
|
)
|
||||||
|
# TODO: IF USER OVERRIDE THE CONTEXT, PASS THAT
|
||||||
if task.async_execution:
|
if task.async_execution:
|
||||||
context = aggregate_raw_outputs_from_task_outputs(task_outputs)
|
context = aggregate_raw_outputs_from_task_outputs(task_outputs)
|
||||||
future = task.execute_async(
|
future = task.execute_async(
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from crewai.utilities.formatter import aggregate_raw_outputs_from_task_outputs
|
|||||||
|
|
||||||
class CrewOutput(BaseModel):
|
class CrewOutput(BaseModel):
|
||||||
output: List[TaskOutput] = Field(description="Result of the final task")
|
output: List[TaskOutput] = Field(description="Result of the final task")
|
||||||
|
# TODO: TYPED OUTPUT
|
||||||
tasks_output: list[TaskOutput] = Field(
|
tasks_output: list[TaskOutput] = Field(
|
||||||
description="Output of each task", default=[]
|
description="Output of each task", default=[]
|
||||||
)
|
)
|
||||||
@@ -15,14 +16,24 @@ class CrewOutput(BaseModel):
|
|||||||
description="Processed token summary", default={}
|
description="Processed token summary", default={}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO: Support 1 output by default
|
||||||
|
# TODO: GIVE THEM THE OPTION TO ACCESS
|
||||||
|
# TODO: RESULT get's back a string
|
||||||
|
|
||||||
# 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."""
|
||||||
|
if len(self.output) == 1:
|
||||||
|
return self.output[0].result()
|
||||||
|
|
||||||
results = [output.result() for output in self.output]
|
results = [output.result() for output in self.output]
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
# TODO: RESULT PYDANTIC
|
||||||
|
# TODO: RESULT JSON D
|
||||||
|
|
||||||
def raw_output(self) -> str:
|
def raw_output(self) -> str:
|
||||||
"""Return the raw output of the task."""
|
"""Return the raw output of the task."""
|
||||||
return aggregate_raw_outputs_from_task_outputs(self.output)
|
return aggregate_raw_outputs_from_task_outputs(self.output)
|
||||||
@@ -41,4 +52,5 @@ class CrewOutput(BaseModel):
|
|||||||
|
|
||||||
# TODO: Confirm with Joao that we want to print the raw output and not the object
|
# TODO: Confirm with Joao that we want to print the raw output and not the object
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
# TODO: GRAB LAST TASK AND CALL RESULT ON IT.
|
||||||
return str(self.raw_output())
|
return str(self.raw_output())
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ from pydantic import BaseModel, Field, model_validator
|
|||||||
class TaskOutput(BaseModel):
|
class TaskOutput(BaseModel):
|
||||||
"""Class that represents the result of a task."""
|
"""Class that represents the result of a task."""
|
||||||
|
|
||||||
|
# TODO: MAKE SURE TO FULLY SUPPORT OUTPUT FILE
|
||||||
|
|
||||||
description: str = Field(description="Description of the task")
|
description: str = Field(description="Description of the task")
|
||||||
summary: Optional[str] = Field(description="Summary of the task", default=None)
|
summary: Optional[str] = Field(description="Summary of the task", default=None)
|
||||||
raw_output: str = Field(description="Result of the task")
|
raw_output: str = Field(description="Result of the task")
|
||||||
@@ -43,7 +45,7 @@ class TaskOutput(BaseModel):
|
|||||||
return self.json_output[key]
|
return self.json_output[key]
|
||||||
raise KeyError(f"Key '{key}' not found in pydantic_output or json_output")
|
raise KeyError(f"Key '{key}' not found in pydantic_output or json_output")
|
||||||
|
|
||||||
def to_output_dict(self) -> Dict[str, Any]:
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
"""Convert json_output and pydantic_output to a dictionary."""
|
"""Convert json_output and pydantic_output to a dictionary."""
|
||||||
output_dict = {}
|
output_dict = {}
|
||||||
if self.json_output:
|
if self.json_output:
|
||||||
|
|||||||
Reference in New Issue
Block a user