Storing & Retrieving Memory

Overview

Memorylake enables storing, retrieving and managing conversational memory by associating user queries and responses with specific sessions. This allows AI-driven applications to recall past interactions and provide context-aware responses.


Method: short_memory_create()

The short_memory_create() method stores a memory instance for a specific user. Each memory entry contains:

  • User UUID: Identifies the user.

  • Memory Context: Defines the scope of memory storage (e.g., chatbot session).

  • Memory Data: Stores the user’s query, AI-generated response, timestamp, and cache expiration time.

Example Method

user_uuid = "user123"
memory_context = {
    "context_entity_id": "chatbot",
    "context_id": "session1",
    "memory_id": "msg001"
}
memory = {
    "query_text": "Hello!",
    "response_text": "Hi there! How can I help you?",
    "time": "2025-02-05T12:00:00Z",
    "cache_ttl": 3600
}

response = memory_lake.short_memory_create(user_uuid, memory_context, memory)
print(response)

Retrieving Memory

You can retrieve memory using the short_memory_read method. This method supports:

response = memory_lake.short_memory_read(user_uuid, memory_context)
print(response)

Last updated