mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
Add missing @functools.wraps when wrapping functions and preserve wrapped class name in @CrewBase. (#1560)
* Update annotations.py * Update utils.py * Update crew_base.py * Update utils.py * Update crew_base.py --------- Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com>
This commit is contained in:
@@ -66,6 +66,8 @@ def cache_handler(func):
|
||||
|
||||
|
||||
def crew(func) -> Callable[..., Crew]:
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(self, *args, **kwargs) -> Crew:
|
||||
instantiated_tasks = []
|
||||
instantiated_agents = []
|
||||
|
||||
@@ -213,4 +213,8 @@ def CrewBase(cls: T) -> T:
|
||||
callback_functions[callback]() for callback in callbacks
|
||||
]
|
||||
|
||||
# Include base class (qual)name in the wrapper class (qual)name.
|
||||
WrappedClass.__name__ = CrewBase.__name__ + "(" + cls.__name__ + ")"
|
||||
WrappedClass.__qualname__ = CrewBase.__qualname__ + "(" + cls.__name__ + ")"
|
||||
|
||||
return cast(T, WrappedClass)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from functools import wraps
|
||||
|
||||
def memoize(func):
|
||||
cache = {}
|
||||
|
||||
@wraps(func)
|
||||
def memoized_func(*args, **kwargs):
|
||||
key = (args, tuple(kwargs.items()))
|
||||
if key not in cache:
|
||||
cache[key] = func(*args, **kwargs)
|
||||
return cache[key]
|
||||
|
||||
memoized_func.__dict__.update(func.__dict__)
|
||||
return memoized_func
|
||||
|
||||
Reference in New Issue
Block a user