store method

Memory store(
  1. Perception event, {
  2. Duration retention = const Duration(days: 7),
  3. double initialStrength = 1.0,
  4. Map<String, dynamic>? context,
})

Stores a Perception as a new episodic memory.

Returns the created Memory object.

Implementation

Memory store(
  Perception event, {
  Duration retention = const Duration(days: 7),
  double initialStrength = 1.0,
  Map<String, dynamic>? context,
}) {
  if (_store.length >= capacity) _evictOldest();

  final memory = Memory(
    id: _uuid.v4(),
    content: event.rawInput,
    type: MemoryType.episodic,
    timestamp: event.timestamp,
    emotionalValence: EmotionalValence.neutral,
    strength: initialStrength,
    associatedConceptIds: event.tokens.take(10).toList(),
    context: context ?? {'modality': event.modality.name},
  );

  _store[memory.id] = memory;
  _insertionOrder.add(memory.id);

  _logger.debug(
      'Stored episode: "${_truncate(event.rawInput)}" '
      '(strength: ${initialStrength.toStringAsFixed(2)})');

  return memory;
}