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:
Vini Brasil
2024-08-15 22:24:41 +01:00
committed by GitHub
parent d0707fac91
commit dbf2570353
5 changed files with 43 additions and 2 deletions

View File

@@ -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):