Class: Engram::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/engram/record.rb

Overview

A single unit of memory.

‘id` is assigned by the store on persistence (nil until then); consolidation uses it to target UPDATE/FORGET. `scope` namespaces memories to an owner (e.g. “user:42”). `kind` is a memory type (semantic / episodic / preference).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, scope:, id: nil, embedding: nil, kind: :semantic, importance: 1.0, metadata: {}, created_at: nil, last_accessed_at: nil) ⇒ Record

Returns a new instance of Record.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/engram/record.rb', line 14

def initialize(content:, scope:, id: nil, embedding: nil, kind: :semantic,
  importance: 1.0, metadata: {}, created_at: nil, last_accessed_at: nil)
  @id = id
  @content = content
  @scope = scope
  @embedding = embedding
  @kind = kind
  @importance = importance
  @metadata = 
  @created_at = created_at || Time.now
  @last_accessed_at = last_accessed_at
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



11
12
13
# File 'lib/engram/record.rb', line 11

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



11
12
13
# File 'lib/engram/record.rb', line 11

def created_at
  @created_at
end

#embeddingObject (readonly)

Returns the value of attribute embedding.



11
12
13
# File 'lib/engram/record.rb', line 11

def embedding
  @embedding
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/engram/record.rb', line 10

def id
  @id
end

#importanceObject (readonly)

Returns the value of attribute importance.



11
12
13
# File 'lib/engram/record.rb', line 11

def importance
  @importance
end

#kindObject (readonly)

Returns the value of attribute kind.



11
12
13
# File 'lib/engram/record.rb', line 11

def kind
  @kind
end

#last_accessed_atObject

Returns the value of attribute last_accessed_at.



10
11
12
# File 'lib/engram/record.rb', line 10

def last_accessed_at
  @last_accessed_at
end

#metadataObject (readonly)

Returns the value of attribute metadata.



11
12
13
# File 'lib/engram/record.rb', line 11

def 
  @metadata
end

#scopeObject (readonly)

Returns the value of attribute scope.



11
12
13
# File 'lib/engram/record.rb', line 11

def scope
  @scope
end

Instance Method Details

#to_hObject



27
28
29
30
31
32
33
# File 'lib/engram/record.rb', line 27

def to_h
  {
    id: id, content: content, scope: scope, embedding: embedding, kind: kind,
    importance: importance, metadata: ,
    created_at: created_at, last_accessed_at: last_accessed_at
  }
end