mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Fixed the issue 2123 around memory command with CLI (#2155)
* Fixed the issue 2123 around memory command with CLI * Fixed typo, added the recommendations * Fixed Typo * Fixed lint issue * Fixed the print statement to include path as well --------- Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com>
This commit is contained in:
committed by
Brandon Hancock
parent
48d2b8c320
commit
5db512bef6
@@ -506,7 +506,7 @@ my_crew = Crew(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Resetting Memory
|
### Resetting Memory via cli
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
crewai reset-memories [OPTIONS]
|
crewai reset-memories [OPTIONS]
|
||||||
@@ -520,8 +520,46 @@ crewai reset-memories [OPTIONS]
|
|||||||
| `-s`, `--short` | Reset SHORT TERM memory. | Flag (boolean) | False |
|
| `-s`, `--short` | Reset SHORT TERM memory. | Flag (boolean) | False |
|
||||||
| `-e`, `--entities` | Reset ENTITIES memory. | Flag (boolean) | False |
|
| `-e`, `--entities` | Reset ENTITIES memory. | Flag (boolean) | False |
|
||||||
| `-k`, `--kickoff-outputs` | Reset LATEST KICKOFF TASK OUTPUTS. | 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 |
|
| `-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
|
||||||
|
|
||||||
|
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. |
|
||||||
|
|
||||||
|
|
||||||
## Benefits of Using CrewAI's Memory System
|
## Benefits of Using CrewAI's Memory System
|
||||||
|
|
||||||
|
|||||||
@@ -257,11 +257,11 @@ def get_crew(crew_path: str = "crew.py", require: bool = False) -> Crew | None:
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
for root, _, files in os.walk("."):
|
for root, _, files in os.walk("."):
|
||||||
if "crew.py" in files:
|
if crew_path in files:
|
||||||
crew_path = os.path.join(root, "crew.py")
|
crew_os_path = os.path.join(root, crew_path)
|
||||||
try:
|
try:
|
||||||
spec = importlib.util.spec_from_file_location(
|
spec = importlib.util.spec_from_file_location(
|
||||||
"crew_module", crew_path
|
"crew_module", crew_os_path
|
||||||
)
|
)
|
||||||
if not spec or not spec.loader:
|
if not spec or not spec.loader:
|
||||||
continue
|
continue
|
||||||
@@ -273,9 +273,11 @@ def get_crew(crew_path: str = "crew.py", require: bool = False) -> Crew | None:
|
|||||||
for attr_name in dir(module):
|
for attr_name in dir(module):
|
||||||
attr = getattr(module, attr_name)
|
attr = getattr(module, attr_name)
|
||||||
try:
|
try:
|
||||||
if callable(attr) and hasattr(attr, "crew"):
|
if isinstance(attr, Crew) and hasattr(attr, "kickoff"):
|
||||||
crew_instance = attr().crew()
|
print(
|
||||||
return crew_instance
|
f"Found valid crew object in attribute '{attr_name}' at {crew_os_path}."
|
||||||
|
)
|
||||||
|
return attr
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error processing attribute {attr_name}: {e}")
|
print(f"Error processing attribute {attr_name}: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user