mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +00:00
Adds Task key to the output to back ref to it on callbacks/webhooks
This commit is contained in:
@@ -373,6 +373,7 @@ class Task(BaseModel):
|
||||
|
||||
pydantic_output, json_output = self._export_output(result)
|
||||
task_output = TaskOutput(
|
||||
key=self.key,
|
||||
name=self.name,
|
||||
description=self.description,
|
||||
expected_output=self.expected_output,
|
||||
|
||||
@@ -9,6 +9,7 @@ from crewai.tasks.output_format import OutputFormat
|
||||
class TaskOutput(BaseModel):
|
||||
"""Class that represents the result of a task."""
|
||||
|
||||
key: Optional[str] = Field(description="Key of the task", default=None)
|
||||
description: str = Field(description="Description of the task")
|
||||
name: Optional[str] = Field(description="Name of the task", default=None)
|
||||
expected_output: Optional[str] = Field(
|
||||
|
||||
@@ -111,6 +111,7 @@ def test_task_callback():
|
||||
task.execute_sync(agent=researcher)
|
||||
task_completed.assert_called_once_with(task.output)
|
||||
|
||||
assert task.output.key == task.key
|
||||
assert task.output.description == task.description
|
||||
assert task.output.expected_output == task.expected_output
|
||||
assert task.output.name == task.name
|
||||
@@ -149,6 +150,7 @@ def test_task_callback_returns_task_output():
|
||||
assert isinstance(callback_data, str)
|
||||
output_dict = json.loads(callback_data)
|
||||
expected_output = {
|
||||
"key": task.key,
|
||||
"description": task.description,
|
||||
"raw": "exported_ok",
|
||||
"pydantic": None,
|
||||
|
||||
Reference in New Issue
Block a user