Module: Legion::Extensions::Agentic::Integration::SituationModel::Runners::SituationModel
- Includes:
- Helpers::Lex
- Included in:
- Client, Helpers::Client
- Defined in:
- lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb
Instance Method Summary collapse
- #add_situation_event(model_id:, content:, **opts) ⇒ Object
- #create_situation_model(label:) ⇒ Object
- #find_situation_boundaries(model_id:, threshold: 0.3) ⇒ Object
- #most_coherent_situations(limit: 5) ⇒ Object
- #situation_dimension_trajectory(model_id:, dimension:) ⇒ Object
- #situation_model_coherence(model_id:) ⇒ Object
- #situation_model_stats ⇒ Object
- #situations_by_label(label:) ⇒ Object
- #update_situation_models ⇒ Object
Instance Method Details
#add_situation_event(model_id:, content:, **opts) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 19 def add_situation_event(model_id:, content:, **opts) dim_values = { space: opts.fetch(:space, 0.5), time: opts.fetch(:time, 0.5), causation: opts.fetch(:causation, 0.5), intentionality: opts.fetch(:intentionality, 0.5), protagonist: opts.fetch(:protagonist, 0.5) } event = engine.add_event_to_model(model_id: model_id, content: content, dimension_values: dim_values) unless event log.debug("[situation_model] add_event: model_id=#{model_id} not found") return { success: false, error: 'model not found' } end coherence = engine.model_coherence(model_id: model_id) log.debug("[situation_model] add_event: model_id=#{model_id} coherence=#{coherence.round(3)}") { success: true, event: event.to_h, coherence: coherence } end |
#create_situation_model(label:) ⇒ Object
13 14 15 16 17 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 13 def create_situation_model(label:, **) model = engine.create_model(label: label) log.debug("[situation_model] create_model: id=#{model.id} label=#{label}") { success: true, model: model.to_h } end |
#find_situation_boundaries(model_id:, threshold: 0.3) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 46 def find_situation_boundaries(model_id:, threshold: 0.3, **) boundaries = engine.find_boundaries(model_id: model_id, threshold: threshold) log.debug("[situation_model] boundaries: model_id=#{model_id} count=#{boundaries&.size}") return { success: false, error: 'model not found' } if boundaries.nil? { success: true, model_id: model_id, boundaries: boundaries, threshold: threshold } end |
#most_coherent_situations(limit: 5) ⇒ Object
63 64 65 66 67 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 63 def most_coherent_situations(limit: 5, **) models = engine.most_coherent(limit: limit) log.debug("[situation_model] most_coherent: limit=#{limit} found=#{models.size}") { success: true, models: models.map(&:to_h), count: models.size } end |
#situation_dimension_trajectory(model_id:, dimension:) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 54 def situation_dimension_trajectory(model_id:, dimension:, **) dim = dimension.to_sym trajectory = engine.dimension_trajectory(model_id: model_id, dimension: dim) log.debug("[situation_model] trajectory: model_id=#{model_id} dimension=#{dim} points=#{trajectory&.size}") return { success: false, error: 'model not found' } if trajectory.nil? { success: true, model_id: model_id, dimension: dim, trajectory: trajectory } end |
#situation_model_coherence(model_id:) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 38 def situation_model_coherence(model_id:, **) coherence = engine.model_coherence(model_id: model_id) log.debug("[situation_model] coherence: model_id=#{model_id} value=#{coherence}") return { success: false, error: 'model not found' } if coherence.nil? { success: true, model_id: model_id, coherence: coherence } end |
#situation_model_stats ⇒ Object
82 83 84 85 86 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 82 def situation_model_stats(**) stats = engine.to_h log.debug("[situation_model] stats: model_count=#{stats[:model_count]}") { success: true, **stats } end |
#situations_by_label(label:) ⇒ Object
69 70 71 72 73 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 69 def situations_by_label(label:, **) models = engine.models_by_label(label: label) log.debug("[situation_model] by_label: label=#{label} found=#{models.size}") { success: true, label: label, models: models.map(&:to_h), count: models.size } end |
#update_situation_models ⇒ Object
75 76 77 78 79 80 |
# File 'lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb', line 75 def update_situation_models(**) engine.decay_all pruned = engine.prune_collapsed log.debug("[situation_model] update: decay_all pruned=#{pruned.size}") { success: true, pruned_count: pruned.size } end |