Class: OpenAISwarm::Memories::EntityStore
- Inherits:
-
Object
- Object
- OpenAISwarm::Memories::EntityStore
- Defined in:
- lib/ruby-openai-swarm/memories/entity_store.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#entity_store ⇒ Object
Returns the value of attribute entity_store.
Instance Method Summary collapse
- #add_entities(entities) ⇒ Object
- #entity_store_save ⇒ Object
-
#initialize(entity_store = nil) ⇒ EntityStore
constructor
A new instance of EntityStore.
- #memories ⇒ Object
Constructor Details
#initialize(entity_store = nil) ⇒ EntityStore
7 8 9 10 |
# File 'lib/ruby-openai-swarm/memories/entity_store.rb', line 7 def initialize(entity_store = nil) @entity_store = entity_store @data = entity_store&.data || {} end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/ruby-openai-swarm/memories/entity_store.rb', line 4 def data @data end |
#entity_store ⇒ Object
Returns the value of attribute entity_store.
4 5 6 |
# File 'lib/ruby-openai-swarm/memories/entity_store.rb', line 4 def entity_store @entity_store end |
Instance Method Details
#add_entities(entities) ⇒ Object
18 19 20 21 |
# File 'lib/ruby-openai-swarm/memories/entity_store.rb', line 18 def add_entities(entities) entities.each { |key, value| @data[key.to_sym] = value } entity_store_save end |
#entity_store_save ⇒ Object
12 13 14 15 16 |
# File 'lib/ruby-openai-swarm/memories/entity_store.rb', line 12 def entity_store_save return unless entity_store.respond_to?(:update) entity_store.update(data: data) end |
#memories ⇒ Object
23 24 25 |
# File 'lib/ruby-openai-swarm/memories/entity_store.rb', line 23 def memories data&.to_json end |