Class: RobotLab::Durable::Reflector
- Inherits:
-
Object
- Object
- RobotLab::Durable::Reflector
- Defined in:
- lib/robot_lab/durable/reflector.rb
Instance Method Summary collapse
-
#initialize(store:, domain:) ⇒ Reflector
constructor
A new instance of Reflector.
-
#reflect(learnings) ⇒ Object
Examine plain-text learnings accumulated during a session and promote any that are not already represented in the store.
Constructor Details
#initialize(store:, domain:) ⇒ Reflector
Returns a new instance of Reflector.
6 7 8 9 |
# File 'lib/robot_lab/durable/reflector.rb', line 6 def initialize(store:, domain:) @store = store @domain = domain.to_s end |
Instance Method Details
#reflect(learnings) ⇒ Object
Examine plain-text learnings accumulated during a session and promote any that are not already represented in the store.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/robot_lab/durable/reflector.rb', line 15 def reflect(learnings) Array(learnings).each do |text| next if text.nil? || text.strip.empty? text = text.strip next if already_stored?(text) now = Time.now.iso8601 @store.record( Entry.new( content: text, reasoning: "Observed during session (auto-promoted by Reflector)", category: :pattern, domain: @domain, confidence: 0.1, use_count: 0, created_at: now, updated_at: now ) ) end end |