mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +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:
@@ -14,6 +14,14 @@ class SimpleCrew:
|
||||
def simple_task(self):
|
||||
return Task(description="Simple Description", expected_output="Simple Output")
|
||||
|
||||
@task
|
||||
def custom_named_task(self):
|
||||
return Task(
|
||||
description="Simple Description",
|
||||
expected_output="Simple Output",
|
||||
name="Custom",
|
||||
)
|
||||
|
||||
|
||||
def test_agent_memoization():
|
||||
crew = SimpleCrew()
|
||||
@@ -33,3 +41,15 @@ def test_task_memoization():
|
||||
assert (
|
||||
first_call_result is second_call_result
|
||||
), "Task memoization is not working as expected"
|
||||
|
||||
|
||||
def test_task_name():
|
||||
simple_task = SimpleCrew().simple_task()
|
||||
assert (
|
||||
simple_task.name == "simple_task"
|
||||
), "Task name is not inferred from function name as expected"
|
||||
|
||||
custom_named_task = SimpleCrew().custom_named_task()
|
||||
assert (
|
||||
custom_named_task.name == "Custom"
|
||||
), "Custom task name is not being set as expected"
|
||||
|
||||
Reference in New Issue
Block a user