praval.memory.episodic_memory
Episodic memory for Praval agents - conversation history and experiences
This manages: - Conversation turns and dialogue history - Agent interaction sequences - Temporal event chains - Experience-based learning patterns
Classes
|
Manages episodic memories - experiences and conversations over time |
- class praval.memory.episodic_memory.EpisodicMemory(long_term_memory, short_term_memory, conversation_window=50, episode_lifetime_days=30)[source]
Bases:
objectManages episodic memories - experiences and conversations over time
Features: - Conversation turn tracking - Experience sequencing - Temporal relationship modeling - Context window management
- Parameters:
long_term_memory (LongTermMemory)
short_term_memory (ShortTermMemory)
conversation_window (int)
episode_lifetime_days (int)
- __init__(long_term_memory, short_term_memory, conversation_window=50, episode_lifetime_days=30)[source]
Initialize episodic memory
- Parameters:
long_term_memory (
LongTermMemory) – Long-term memory backendshort_term_memory (
ShortTermMemory) – Short-term memory backendconversation_window (
int) – Number of conversation turns to keep in contextepisode_lifetime_days (
int) – How long to keep episodes before archiving
- store_conversation_turn(agent_id, user_message, agent_response, context=None)[source]
Store a conversation turn as an episodic memory
- Parameters:
agent_id (
str) – The agent involved in the conversationuser_message (
str) – The user’s messageagent_response (
str) – The agent’s responsecontext (
Optional[Dict[str,Any]]) – Additional context information
- Return type:
str- Returns:
The memory ID
- store_experience(agent_id, experience_type, experience_data, outcome, success=True)[source]
Store an experience or learning episode
- Parameters:
agent_id (
str) – The agent that had the experienceexperience_type (
str) – Type of experience (e.g., “task_completion”,"problem_solving")
experience_data (
Dict[str,Any]) – Data about the experienceoutcome (
str) – The result or outcomesuccess (
bool) – Whether the experience was successful
- Return type:
str- Returns:
The memory ID
- get_conversation_context(agent_id, turns=None)[source]
Get recent conversation context for an agent
- Parameters:
agent_id (
str) – The agent to get context forturns (
Optional[int]) – Number of conversation turns (default: conversation_window)
- Return type:
List[MemoryEntry]- Returns:
List of recent conversation memories
- get_similar_experiences(agent_id, experience_description, limit=5)[source]
Find similar past experiences for an agent
- Parameters:
agent_id (
str) – The agent to search experiences forexperience_description (
str) – Description of the current experiencelimit (
int) – Maximum number of similar experiences to return
- Return type:
- Returns:
Search results with similar experiences
- get_episode_timeline(agent_id, start_time, end_time)[source]
Get episodic memories within a time range
- Parameters:
agent_id (
str) – The agent to get timeline forstart_time (
datetime) – Start of the time rangeend_time (
datetime) – End of the time range
- Return type:
List[MemoryEntry]- Returns:
List of episodic memories in chronological order