mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Add name and expected_output to TaskOutput (#1199)
* Add name and expected_output to TaskOutput This commit adds task information to the TaskOutput class. This is useful to provide extra context to callbacks. * Populate task name from function names This commit populates task name from function names when using annotations.
This commit is contained in:
@@ -6,12 +6,20 @@ def task(func):
|
||||
task.registration_order = []
|
||||
|
||||
func.is_task = True
|
||||
wrapped_func = memoize(func)
|
||||
memoized_func = memoize(func)
|
||||
|
||||
# Append the function name to the registration order list
|
||||
task.registration_order.append(func.__name__)
|
||||
|
||||
return wrapped_func
|
||||
def wrapper(*args, **kwargs):
|
||||
result = memoized_func(*args, **kwargs)
|
||||
|
||||
if not result.name:
|
||||
result.name = func.__name__
|
||||
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def agent(func):
|
||||
|
||||
@@ -240,7 +240,9 @@ class Task(BaseModel):
|
||||
pydantic_output, json_output = self._export_output(result)
|
||||
|
||||
task_output = TaskOutput(
|
||||
name=self.name,
|
||||
description=self.description,
|
||||
expected_output=self.expected_output,
|
||||
raw=result,
|
||||
pydantic=pydantic_output,
|
||||
json_dict=json_output,
|
||||
|
||||
@@ -10,6 +10,10 @@ class TaskOutput(BaseModel):
|
||||
"""Class that represents the result of a task."""
|
||||
|
||||
description: str = Field(description="Description of the task")
|
||||
name: Optional[str] = Field(description="Name of the task", default=None)
|
||||
expected_output: Optional[str] = Field(
|
||||
description="Expected output of the task", default=None
|
||||
)
|
||||
summary: Optional[str] = Field(description="Summary of the task", default=None)
|
||||
raw: str = Field(description="Raw output of the task", default="")
|
||||
pydantic: Optional[BaseModel] = Field(
|
||||
|
||||
Reference in New Issue
Block a user