Class: Engram::Record
- Inherits:
-
Object
- Object
- Engram::Record
- 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
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#embedding ⇒ Object
readonly
Returns the value of attribute embedding.
-
#id ⇒ Object
Returns the value of attribute id.
-
#importance ⇒ Object
readonly
Returns the value of attribute importance.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#last_accessed_at ⇒ Object
Returns the value of attribute last_accessed_at.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(content:, scope:, id: nil, embedding: nil, kind: :semantic, importance: 1.0, metadata: {}, created_at: nil, last_accessed_at: nil) ⇒ Record
constructor
A new instance of Record.
- #to_h ⇒ Object
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 = @kind = kind @importance = importance @metadata = @created_at = created_at || Time.now @last_accessed_at = last_accessed_at end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
11 12 13 |
# File 'lib/engram/record.rb', line 11 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
11 12 13 |
# File 'lib/engram/record.rb', line 11 def created_at @created_at end |
#embedding ⇒ Object (readonly)
Returns the value of attribute embedding.
11 12 13 |
# File 'lib/engram/record.rb', line 11 def @embedding end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/engram/record.rb', line 10 def id @id end |
#importance ⇒ Object (readonly)
Returns the value of attribute importance.
11 12 13 |
# File 'lib/engram/record.rb', line 11 def importance @importance end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
11 12 13 |
# File 'lib/engram/record.rb', line 11 def kind @kind end |
#last_accessed_at ⇒ Object
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 |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/engram/record.rb', line 11 def @metadata end |
#scope ⇒ Object (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_h ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/engram/record.rb', line 27 def to_h { id: id, content: content, scope: scope, embedding: , kind: kind, importance: importance, metadata: , created_at: created_at, last_accessed_at: last_accessed_at } end |