Overview

The Memory Timestamps feature allows you to specify when a memory was created, regardless of when it’s actually added to the system. This powerful capability enables you to:

  • Maintain accurate chronological ordering of memories
  • Import historical data with proper timestamps
  • Create memories that reflect when events actually occurred
  • Build timelines with precise temporal information

By leveraging custom timestamps, you can ensure that your memory system maintains an accurate representation of when information was generated or events occurred.

Benefits of Custom Timestamps

Custom timestamps offer several important benefits:

Historical Accuracy: Preserve the exact timing of past events and information.

Data Migration: Seamlessly migrate existing data while maintaining original timestamps.

Time-Sensitive Analysis: Enable time-based analysis and pattern recognition across memories.

Consistent Chronology: Maintain proper ordering of memories for coherent storytelling.

Using Custom Timestamps

When adding new memories, you can specify a custom timestamp to indicate when the memory was created. This timestamp will be used instead of the current time.

Adding Memories with Custom Timestamps

import time
from datetime import datetime, timedelta

# Get the current time
current_time = datetime.now()

# Calculate 5 days ago
five_days_ago = current_time - timedelta(days=5)

# Convert to Unix timestamp (seconds since epoch)
unix_timestamp = int(five_days_ago.timestamp())

# Add memory with custom timestamp
client.add("I'm travelling to SF", user_id="user1", timestamp=unix_timestamp)

Timestamp Format

When specifying a custom timestamp, you should provide a Unix timestamp (seconds since epoch). This is an integer representing the number of seconds that have elapsed since January 1, 1970 (UTC).

For example, to create a memory with a timestamp of January 1, 2023:

# January 1, 2023 timestamp
january_2023_timestamp = 1672531200  # Unix timestamp for 2023-01-01 00:00:00 UTC

client.add("Important historical information", user_id="user1", timestamp=january_2023_timestamp)

If you have any questions, please feel free to reach out to us using one of the following methods: