-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reseting memory on cli * using storage.reset * deleting memories on command * added tests * handle when no flags are used * added docs
- Loading branch information
1 parent
61a1963
commit be1b9a3
Showing
10 changed files
with
231 additions
and
4 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
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,45 @@ | ||
import subprocess | ||
import click | ||
|
||
from crewai.memory.entity.entity_memory import EntityMemory | ||
from crewai.memory.long_term.long_term_memory import LongTermMemory | ||
from crewai.memory.short_term.short_term_memory import ShortTermMemory | ||
from crewai.utilities.task_output_storage_handler import TaskOutputStorageHandler | ||
|
||
|
||
def reset_memories_command(long, short, entity, kickoff_outputs, all) -> None: | ||
""" | ||
Replay the crew execution from a specific task. | ||
Args: | ||
task_id (str): The ID of the task to replay from. | ||
""" | ||
|
||
try: | ||
if all: | ||
ShortTermMemory().reset() | ||
EntityMemory().reset() | ||
LongTermMemory().reset() | ||
TaskOutputStorageHandler().reset() | ||
click.echo("All memories have been reset.") | ||
else: | ||
if long: | ||
LongTermMemory().reset() | ||
click.echo("Long term memory has been reset.") | ||
|
||
if short: | ||
ShortTermMemory().reset() | ||
click.echo("Short term memory has been reset.") | ||
if entity: | ||
EntityMemory().reset() | ||
click.echo("Entity memory has been reset.") | ||
if kickoff_outputs: | ||
TaskOutputStorageHandler().reset() | ||
click.echo("Latest Kickoff outputs stored has been reset.") | ||
|
||
except subprocess.CalledProcessError as e: | ||
click.echo(f"An error occurred while resetting the memories: {e}", err=True) | ||
click.echo(e.output, err=True) | ||
|
||
except Exception as e: | ||
click.echo(f"An unexpected error occurred: {e}", err=True) |
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
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
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
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