The advanced memory system provides sophisticated memory management with short-term, long-term, entity, and user-specific storage, enhanced by quality scoring and optional graph database support.
Long-term memory persists across sessions and stores important information.
Copy
# Store persistent knowledgememory.store_long_term( text="User works as a data scientist at TechCorp", user_id="user123", quality=0.95, metadata={"type": "user_info", "category": "professional"})# Retrieve with quality filtermemories = memory.search_long_term( query="user profession", user_id="user123", min_quality=0.8)
Entity memory stores information about specific people, places, or things.
Copy
# Store entity informationmemory.store_entity( name="TechCorp", text="TechCorp is a leading AI company founded in 2020", entity_type="organization", metadata={"industry": "technology", "size": "large"})# Search entity informationentity_info = memory.search_entity( name="TechCorp", query="company details")
from praisonaiagents import Agent, Task, PraisonAIAgentsfrom praisonaiagents.memory import Memory# Configure memory with quality scoringmemory_config = { "provider": "rag", "use_embedding": True, "embedding_model": "text-embedding-3-small"}# Create memory instancememory = Memory(memory_config)# Create assistant agentassistant = Agent( name="Personal Assistant", instructions="""You are a personal assistant with perfect memory. Remember user preferences, important information, and context. Always use your memory to provide personalised responses.""", memory=memory, user_id="john_doe")# Create task with memory integrationtask = Task( description="Help me plan my day based on my preferences", agent=assistant, expected_output="Personalised daily schedule")# Run the systemagents = PraisonAIAgents( agents=[assistant], tasks=[task], memory=memory)# Memory automatically:# 1. Retrieves user preferences# 2. Searches relevant past interactions# 3. Builds context for the task# 4. Stores the interaction with quality scoreresult = agents.start()# Store user feedback as high-quality memorymemory.store_long_term( text="User preferred morning schedule with exercise first", user_id="john_doe", completeness=0.9, relevance=1.0, clarity=0.95, accuracy=1.0)