Brandon/cre 211 fix agent and task config for yaml based projects (#1211)

* Fixed agents. Now need to fix tasks.

* Add type fixes and fix task decorator

* Clean up logs

* fix more type errors

* Revert back to required

* Undo changes.

* Remove default none for properties that cannot be none

* Clean up comments

* Implement all of Guis feedback
This commit is contained in:
Brandon Hancock (bhancock_ai)
2024-08-20 09:31:02 -04:00
committed by GitHub
parent 17bffb0803
commit 8119edb495
5 changed files with 117 additions and 52 deletions

View File

@@ -1,3 +1,5 @@
from functools import wraps
from crewai.project.utils import memoize
@@ -5,21 +7,17 @@ def task(func):
if not hasattr(task, "registration_order"):
task.registration_order = []
func.is_task = True
memoized_func = memoize(func)
# Append the function name to the registration order list
task.registration_order.append(func.__name__)
@wraps(func)
def wrapper(*args, **kwargs):
result = memoized_func(*args, **kwargs)
result = func(*args, **kwargs)
if not result.name:
result.name = func.__name__
return result
return wrapper
setattr(wrapper, "is_task", True)
task.registration_order.append(func.__name__)
return memoize(wrapper)
def agent(func):