-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding meomization to crewai project annotations
- Loading branch information
1 parent
2edc88e
commit b264eba
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from crewai.agent import Agent | ||
from crewai.project import agent, task | ||
from crewai.task import Task | ||
|
||
|
||
class SimpleCrew: | ||
@agent | ||
def simple_agent(self): | ||
return Agent( | ||
role="Simple Agent", goal="Simple Goal", backstory="Simple Backstory" | ||
) | ||
|
||
@task | ||
def simple_task(self): | ||
return Task(description="Simple Description", expected_output="Simple Output") | ||
|
||
|
||
def test_agent_memoization(): | ||
crew = SimpleCrew() | ||
first_call_result = crew.simple_agent() | ||
second_call_result = crew.simple_agent() | ||
|
||
assert ( | ||
first_call_result is second_call_result | ||
), "Agent memoization is not working as expected" | ||
|
||
|
||
def test_task_memoization(): | ||
crew = SimpleCrew() | ||
first_call_result = crew.simple_task() | ||
second_call_result = crew.simple_task() | ||
|
||
assert ( | ||
first_call_result is second_call_result | ||
), "Task memoization is not working as expected" |