Class: Pikuri::Memory::Record
- Inherits:
-
Data
- Object
- Data
- Pikuri::Memory::Record
- Defined in:
- lib/pikuri/memory/record.rb
Overview
One memory row as returned by a mem0 server, normalized into a
plain value object. The same shape backs all three read/write
surfaces — add (carries event, no score), search
(carries score, no event), and get_all (neither) — with
the absent fields left nil, so callers can pattern-match on
what's present rather than juggling three near-identical types.
Field provenance (mem0 v3 JSON → this)
id←"id"— the memory's UUID; the handle fordelete.text←"memory"— the fact string. Namedtextso it doesn't shadow the enclosing module (+record.memory+ reads oddly).score←"score"— Qdrant similarity (higher = more relevant);niloutsidesearchresults.created_at←"created_at"— ISO-8601 String. Load-bearing for recall: recency is the consuming LLM's tiebreaker when resolving a stale fact against its correction, so it must travel with the text.metadata←"metadata"— arbitrary Hash;{}when absent.event←"event"—"ADD"/"UPDATE"/"DELETE"/"NONE"on anaddresponse;nilon reads.
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
-
.from(hash) ⇒ Record
Build a Record from one mem0 result Hash (String keys, as Faraday's JSON middleware deserializes them).
Instance Method Summary collapse
-
#created_label ⇒ String?
created_attrimmed to whole-second wall-clock for the prompt: +"2026-06-01T17:04:11.884889+00:00"+ →"2026-06-01 17:04:11"(sub-second precision and offset machinery are token noise when the timestamp is only a recency tiebreaker).
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at
27 28 29 |
# File 'lib/pikuri/memory/record.rb', line 27 def created_at @created_at end |
#event ⇒ Object (readonly)
Returns the value of attribute event
27 28 29 |
# File 'lib/pikuri/memory/record.rb', line 27 def event @event end |
#id ⇒ Object (readonly)
Returns the value of attribute id
27 28 29 |
# File 'lib/pikuri/memory/record.rb', line 27 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
27 28 29 |
# File 'lib/pikuri/memory/record.rb', line 27 def @metadata end |
#score ⇒ Object (readonly)
Returns the value of attribute score
27 28 29 |
# File 'lib/pikuri/memory/record.rb', line 27 def score @score end |
#text ⇒ Object (readonly)
Returns the value of attribute text
27 28 29 |
# File 'lib/pikuri/memory/record.rb', line 27 def text @text end |
Class Method Details
.from(hash) ⇒ Record
Build a Pikuri::Memory::Record from one mem0 result Hash (String keys, as
Faraday's JSON middleware deserializes them). Tolerant of
missing keys — every field but metadata defaults to nil,
and metadata to {} — so the one factory serves add /
search / get_all rows alike.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pikuri/memory/record.rb', line 36 def self.from(hash) new( id: hash['id'], text: hash['memory'], score: hash['score'], created_at: hash['created_at'], metadata: hash['metadata'] || {}, event: hash['event'] ) end |
Instance Method Details
#created_label ⇒ String?
created_at trimmed to whole-second wall-clock for the prompt:
+"2026-06-01T17:04:11.884889+00:00"+ → "2026-06-01 17:04:11"
(sub-second precision and offset machinery are token noise when the
timestamp is only a recency tiebreaker). nil when created_at is
absent; falls back to the raw String on an unparseable value.
54 55 56 57 58 59 60 |
# File 'lib/pikuri/memory/record.rb', line 54 def created_label return nil unless created_at Time.parse(created_at).strftime('%Y-%m-%d %H:%M:%S') rescue ArgumentError created_at end |