Update memory.mdx

This commit is contained in:
João Moura
2025-02-09 16:45:35 -03:00
committed by GitHub
parent af54112788
commit d092da0687

View File

@@ -60,40 +60,47 @@ my_crew = Crew(
```python Code ```python Code
from crewai import Crew, Process from crewai import Crew, Process
from crewai.memory import LongTermMemory, ShortTermMemory, EntityMemory from crewai.memory import LongTermMemory, ShortTermMemory, EntityMemory
from crewai.memory.storage import LTMSQLiteStorage, CustomRAGStorage from crewai.memory.storage import LTMSQLiteStorage, RAGStorage
from typing import List, Optional from typing import List, Optional
# Assemble your crew with memory capabilities # Assemble your crew with memory capabilities
my_crew: Crew = Crew( my_crew: Crew = Crew(
agents: List = [...], agents = [...],
tasks: List = [...], tasks = [...],
process: str = Process.sequential, process = Process.sequential,
memory: bool = True, memory = True,
# Long-term memory for persistent storage across sessions # Long-term memory for persistent storage across sessions
long_term_memory: Optional[LongTermMemory] = LongTermMemory( long_term_memory = LongTermMemory(
storage=LTMSQLiteStorage( storage=LTMSQLiteStorage(
db_path="${CREWAI_STORAGE_DIR}/my_crew1/long_term_memory_storage.db" db_path="/my_crew1/long_term_memory_storage.db"
) )
), ),
# Short-term memory for current context using RAG # Short-term memory for current context using RAG
short_term_memory: Optional[ShortTermMemory] = ShortTermMemory( short_term_memory = ShortTermMemory(
storage=CustomRAGStorage( storage = RAGStorage(
crew_name="my_crew", embedder_config={
storage_type="short_term", "provider": "openai",
data_dir="${CREWAI_STORAGE_DIR}", "config": {
model=embedder["model"], "model": 'text-embedding-3-small'
dimension=embedder["dimension"], }
},
type="short_term",
path="/my_crew1/"
)
), ),
), ),
# Entity memory for tracking key information about entities # Entity memory for tracking key information about entities
entity_memory: Optional[EntityMemory] = EntityMemory( entity_memory = EntityMemory(
storage=CustomRAGStorage( storage=RAGStorage(
crew_name="my_crew", embedder_config={
storage_type="entities", "provider": "openai",
data_dir="${CREWAI_STORAGE_DIR}", "config": {
model=embedder["model"], "model": 'text-embedding-3-small'
dimension=embedder["dimension"], }
), },
type="short_term",
path="/my_crew1/"
)
), ),
verbose=True, verbose=True,
) )