From 92fedb7d6a84d810620abbad23ecb6eae54c14e5 Mon Sep 17 00:00:00 2001 From: Vidit-Ostwal Date: Tue, 18 Feb 2025 00:20:43 +0530 Subject: [PATCH] Fixed the issue 2123 around memory command with CLI --- docs/concepts/memory.mdx | 41 +++++++++++++++++++++++++++++++++++++++- src/crewai/cli/utils.py | 6 +++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/docs/concepts/memory.mdx b/docs/concepts/memory.mdx index ae65db290..d571f6691 100644 --- a/docs/concepts/memory.mdx +++ b/docs/concepts/memory.mdx @@ -506,7 +506,7 @@ my_crew = Crew( ) ``` -### Resetting Memory +### Resetting Memory via cli ```shell crewai reset-memories [OPTIONS] @@ -520,8 +520,47 @@ crewai reset-memories [OPTIONS] | `-s`, `--short` | Reset SHORT TERM memory. | Flag (boolean) | False | | `-e`, `--entities` | Reset ENTITIES memory. | Flag (boolean) | False | | `-k`, `--kickoff-outputs` | Reset LATEST KICKOFF TASK OUTPUTS. | Flag (boolean) | False | +| `-kn`, `--knowledge` | Reset KNOWLEDEGE storage | Flag (boolean) | False | | `-a`, `--all` | Reset ALL memories. | Flag (boolean) | False | +Note: To use the cli command you need to have your crew in a file called crew.py in the same directory. + + + + +### Resetting Memory via crew object + +```python code + +my_crew = Crew( + agents=[...], + tasks=[...], + process=Process.sequential, + memory=True, + verbose=True, + embedder={ + "provider": "custom", + "config": { + "embedder": CustomEmbedder() + } + } +) + +my_crew.reset_memories(command_type = 'all') # Resets all the memory +``` + +#### Resetting Memory Options + +| Command Type | Description | +| :----------------- | :------------------------------- | +| `long` | Reset LONG TERM memory. | +| `short` | Reset SHORT TERM memory. | +| `entities` | Reset ENTITIES memory. | +| `kickoff_outputs` | Reset LATEST KICKOFF TASK OUTPUTS. | +| `knowledge` | Reset KNOWLEDGE memory. | +| `all` | Reset ALL memories. | + +Note: To use the cli command you need to have your crew in a file called crew.py in the same directory. ## Benefits of Using CrewAI's Memory System diff --git a/src/crewai/cli/utils.py b/src/crewai/cli/utils.py index 60eb2488a..f7f2f65c9 100644 --- a/src/crewai/cli/utils.py +++ b/src/crewai/cli/utils.py @@ -273,9 +273,9 @@ def get_crew(crew_path: str = "crew.py", require: bool = False) -> Crew | None: for attr_name in dir(module): attr = getattr(module, attr_name) try: - if callable(attr) and hasattr(attr, "crew"): - crew_instance = attr().crew() - return crew_instance + if not callable(attr) and hasattr(attr, "kickoff"): + print(f"Found valid crew object in attribute '{attr_name}'.") + return attr except Exception as e: print(f"Error processing attribute {attr_name}: {e}")