Module: Legion::Extensions::Agentic::Memory::Episodic::Runners::EpisodicBuffer
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb
Instance Method Summary collapse
- #add_binding(episode_id:, modality:, content:, source:, strength: Helpers::Constants::DEFAULT_BINDING_STRENGTH) ⇒ Object
- #attend_episode(episode_id:) ⇒ Object
- #check_integration(episode_id:) ⇒ Object
- #create_episode ⇒ Object
- #episodic_buffer_stats ⇒ Object
- #most_coherent(limit: 5) ⇒ Object
- #rehearse_episode(episode_id:) ⇒ Object
- #retrieve_by_modality(modality:) ⇒ Object
- #retrieve_multimodal ⇒ Object
- #update_episodic_buffer ⇒ Object
Instance Method Details
#add_binding(episode_id:, modality:, content:, source:, strength: Helpers::Constants::DEFAULT_BINDING_STRENGTH) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 17 def add_binding(episode_id:, modality:, content:, source:, strength: Helpers::Constants::DEFAULT_BINDING_STRENGTH, **) raise ArgumentError, "invalid modality: #{modality}" unless Helpers::Constants::MODALITIES.include?(modality.to_sym) store = default_store result = store.add_to_episode( episode_id: episode_id, modality: modality.to_sym, content: content, source: source, strength: strength ) if result[:added] log.debug("[episodic_buffer] add_binding ep=#{episode_id[0..7]} mod=#{modality}") { success: true, episode_id: episode_id, binding_id: result[:binding_id] } else log.debug("[episodic_buffer] add_binding failed ep=#{episode_id[0..7]} r=#{result[:reason]}") { success: false, episode_id: episode_id, reason: result[:reason] } end end |
#attend_episode(episode_id:) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 39 def attend_episode(episode_id:, **) store = default_store result = store.attend_episode(episode_id: episode_id) log.debug("[episodic_buffer] attend ep=#{episode_id[0..7]} success=#{result[:success]}") result.merge(success: result[:success]) end |
#check_integration(episode_id:) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 53 def check_integration(episode_id:, **) store = default_store result = store.integrate(episode_id: episode_id) log.debug("[episodic_buffer] check_integration ep=#{episode_id[0..7]} ok=#{result[:integrated]}") result.merge(success: true) end |
#create_episode ⇒ Object
10 11 12 13 14 15 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 10 def create_episode(**) store = default_store episode = store.create_episode log.debug("[episodic_buffer] created episode id=#{episode.id[0..7]}") { success: true, episode_id: episode.id, created_at: episode.created_at } end |
#episodic_buffer_stats ⇒ Object
88 89 90 91 92 93 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 88 def episodic_buffer_stats(**) store = default_store stats = store.to_h log.debug("[episodic_buffer] stats episodes=#{stats[:episode_count]}") { success: true }.merge(stats) end |
#most_coherent(limit: 5) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 74 def most_coherent(limit: 5, **) store = default_store episodes = store.most_coherent(limit: limit) log.debug("[episodic_buffer] most_coherent limit=#{limit} returned=#{episodes.size}") { success: true, count: episodes.size, episodes: episodes.map(&:to_h) } end |
#rehearse_episode(episode_id:) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 46 def rehearse_episode(episode_id:, **) store = default_store result = store.rehearse_episode(episode_id: episode_id) log.debug("[episodic_buffer] rehearse ep=#{episode_id[0..7]} success=#{result[:success]}") result.merge(success: result[:success]) end |
#retrieve_by_modality(modality:) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 60 def retrieve_by_modality(modality:, **) store = default_store episodes = store.retrieve_by_modality(modality: modality.to_sym) log.debug("[episodic_buffer] retrieve_by_modality mod=#{modality} count=#{episodes.size}") { success: true, modality: modality, count: episodes.size, episodes: episodes.map(&:to_h) } end |
#retrieve_multimodal ⇒ Object
67 68 69 70 71 72 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 67 def retrieve_multimodal(**) store = default_store episodes = store.retrieve_multimodal log.debug("[episodic_buffer] retrieve_multimodal count=#{episodes.size}") { success: true, count: episodes.size, episodes: episodes.map(&:to_h) } end |
#update_episodic_buffer ⇒ Object
81 82 83 84 85 86 |
# File 'lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb', line 81 def update_episodic_buffer(**) store = default_store result = store.tick log.debug("[episodic_buffer] tick decayed=#{result[:decayed]} expired=#{result[:expired]}") { success: true }.merge(result) end |