Class: Llmemory::LongTerm::GraphBased::Node

Inherits:
Struct
  • Object
show all
Defined in:
lib/llmemory/long_term/graph_based/node.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



6
7
8
# File 'lib/llmemory/long_term/graph_based/node.rb', line 6

def created_at
  @created_at
end

#entity_typeObject

Returns the value of attribute entity_type

Returns:

  • (Object)

    the current value of entity_type



6
7
8
# File 'lib/llmemory/long_term/graph_based/node.rb', line 6

def entity_type
  @entity_type
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



6
7
8
# File 'lib/llmemory/long_term/graph_based/node.rb', line 6

def id
  @id
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/llmemory/long_term/graph_based/node.rb', line 6

def name
  @name
end

#propertiesObject

Returns the value of attribute properties

Returns:

  • (Object)

    the current value of properties



6
7
8
# File 'lib/llmemory/long_term/graph_based/node.rb', line 6

def properties
  @properties
end

#updated_atObject

Returns the value of attribute updated_at

Returns:

  • (Object)

    the current value of updated_at



6
7
8
# File 'lib/llmemory/long_term/graph_based/node.rb', line 6

def updated_at
  @updated_at
end

#user_idObject

Returns the value of attribute user_id

Returns:

  • (Object)

    the current value of user_id



6
7
8
# File 'lib/llmemory/long_term/graph_based/node.rb', line 6

def user_id
  @user_id
end

Class Method Details

.from_h(hash) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/llmemory/long_term/graph_based/node.rb', line 16

def self.from_h(hash)
  new(
    id: hash[:id] || hash["id"],
    user_id: hash[:user_id] || hash["user_id"],
    entity_type: (hash[:entity_type] || hash["entity_type"]).to_s,
    name: (hash[:name] || hash["name"]).to_s,
    properties: hash[:properties] || hash["properties"] || {},
    created_at: hash[:created_at] || hash["created_at"],
    updated_at: hash[:updated_at] || hash["updated_at"]
  )
end

Instance Method Details

#provenanceObject

Lineage of this node, stored within properties so it round-trips through every backend without a schema change. See Llmemory::Provenance.



30
31
32
33
# File 'lib/llmemory/long_term/graph_based/node.rb', line 30

def provenance
  props = properties || {}
  props[:provenance] || props["provenance"]
end

#to_hObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/llmemory/long_term/graph_based/node.rb', line 35

def to_h
  {
    id: id,
    user_id: user_id,
    entity_type: entity_type,
    name: name,
    properties: properties || {},
    created_at: created_at,
    updated_at: updated_at
  }
end