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

EpisodicMemory(long_term_memory,ย ...[,ย ...])

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: object

Manages episodic memories - experiences and conversations over time

Features: - Conversation turn tracking - Experience sequencing - Temporal relationship modeling - Context window management

Parameters:
__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 backend

  • short_term_memory (ShortTermMemory) โ€“ Short-term memory backend

  • conversation_window (int) โ€“ Number of conversation turns to keep in context

  • episode_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 conversation

  • user_message (str) โ€“ The userโ€™s message

  • agent_response (str) โ€“ The agentโ€™s response

  • context (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 experience

  • experience_type (str) โ€“ Type of experience (e.g., โ€œtask_completionโ€, โ€œproblem_solvingโ€)

  • experience_data (Dict[str, Any]) โ€“ Data about the experience

  • outcome (str) โ€“ The result or outcome

  • success (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 for

  • turns (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 for

  • experience_description (str) โ€“ Description of the current experience

  • limit (int) โ€“ Maximum number of similar experiences to return

Return type:

MemorySearchResult

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 for

  • start_time (datetime) โ€“ Start of the time range

  • end_time (datetime) โ€“ End of the time range

Return type:

List[MemoryEntry]

Returns:

List of episodic memories in chronological order

archive_old_episodes(cutoff_days=None)[source]๏ƒ

Archive old episodic memories (implementation depends on requirements)

Parameters:

cutoff_days (Optional[int]) โ€“ Days after which to archive (default: episode_lifetime_days)

get_stats()[source]๏ƒ

Get episodic memory statistics

Return type:

Dict[str, Any]