praval.memory.memory_manager๏
MemoryManager - Unified interface for all Praval agent memory systems
This coordinates: - Short-term working memory - Long-term vector memory - Episodic conversation memory - Semantic knowledge memory
Classes
|
Unified memory management system for Praval agents |
- class praval.memory.memory_manager.MemoryManager(agent_id, backend='auto', qdrant_url='http://localhost:6333', storage_path=None, collection_name='praval_memories', short_term_max_entries=1000, short_term_retention_hours=24, knowledge_base_path=None)[source]๏
Bases:
objectUnified memory management system for Praval agents
Provides a single interface to: - Store and retrieve memories across all systems - Coordinate between short-term and long-term storage - Manage different types of memory (episodic, semantic, etc.) - Optimize memory access patterns
- Parameters:
- __init__(agent_id, backend='auto', qdrant_url='http://localhost:6333', storage_path=None, collection_name='praval_memories', short_term_max_entries=1000, short_term_retention_hours=24, knowledge_base_path=None)[source]๏
Initialize the unified memory manager
- Parameters:
agent_id (
str) โ ID of the agent using this memorybackend (
str) โ Memory backend (โautoโ, โchromadbโ, โqdrantโ, โmemoryโ)qdrant_url (
str) โ URL for Qdrant vector databasestorage_path (
Optional[str]) โ Path for persistent storagecollection_name (
str) โ Collection name for vector storageshort_term_max_entries (
int) โ Max entries in short-term memoryshort_term_retention_hours (
int) โ Short-term memory retention timeknowledge_base_path (
Optional[str]) โ Path to knowledge base files to auto-index
- store_memory(agent_id, content, memory_type=MemoryType.SHORT_TERM, metadata=None, importance=0.5, store_long_term=None)[source]๏
Store a memory entry
- Parameters:
agent_id (
str) โ The agent storing the memorycontent (
str) โ The memory contentmemory_type (
MemoryType) โ Type of memoryimportance (
float) โ Importance score (0.0 to 1.0)store_long_term (
bool) โ Whether to store in long-term memory (auto-decided if None)
- Return type:
- Returns:
Memory ID
- retrieve_memory(memory_id)[source]๏
Retrieve a specific memory by ID
- Parameters:
memory_id (
str) โ The memory ID- Return type:
- Returns:
The memory entry if found
- search_memories(query)[source]๏
Search memories across all systems
- Parameters:
query (
MemoryQuery) โ The search query- Return type:
- Returns:
Combined search results
- get_conversation_context(agent_id, turns=10)[source]๏
Get recent conversation context for an agent
- Parameters:
- Return type:
- Returns:
List of conversation memories
- store_conversation_turn(agent_id, user_message, agent_response, context=None)[source]๏
Store a conversation turn
- store_knowledge(agent_id, knowledge, domain='general', confidence=1.0, knowledge_type='fact')[source]๏
Store knowledge or facts
- get_domain_knowledge(agent_id, domain, limit=20)[source]๏
Get knowledge in a specific domain
- Parameters:
- Return type:
- Returns:
List of knowledge entries
- clear_agent_memories(agent_id, memory_types=None)[source]๏
Clear memories for a specific agent
- Parameters:
agent_id (
str) โ The agent IDmemory_types (
Optional[List[MemoryType]]) โ Types of memory to clear (all if None)
- recall_by_id(memory_id)[source]๏
Recall a specific memory by ID (for spore references)
- Return type:
- Parameters:
memory_id (str)