Module: Legion::Extensions::Agentic::Attention::RelevanceTheory::Runners::RelevanceTheory
- Includes:
- Helpers::Lex
- Included in:
- Helpers::Client
- Defined in:
- lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb
Instance Method Summary collapse
- #assess_input_relevance(input_id:) ⇒ Object
- #attention_budget_report ⇒ Object
- #context_relevance_report(context:) ⇒ Object
- #most_relevant_inputs(limit: 5) ⇒ Object
- #relevance_theory_stats ⇒ Object
- #strengthen_relevance(input_id:, amount: 0.1) ⇒ Object
- #submit_relevance_input(content:, input_type:, context:, cognitive_effect: nil, processing_effort: nil, effect_type: nil, source_id: nil) ⇒ Object
- #update_relevance_theory ⇒ Object
- #weaken_relevance(input_id:, amount: 0.1) ⇒ Object
- #worth_processing_report ⇒ Object
Instance Method Details
#assess_input_relevance(input_id:) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 29 def assess_input_relevance(input_id:, **) result = engine.assess_relevance(input_id: input_id) log.debug("[relevance_theory] assess id=#{input_id[0..7]} " \ "relevance=#{result[:normalized]}") result end |
#attention_budget_report ⇒ Object
67 68 69 70 71 72 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 67 def attention_budget_report(**) budget = engine.attention_budget log.debug('[relevance_theory] attention_budget ' \ "ratio=#{budget[:processing_ratio]}") { success: true }.merge(budget) end |
#context_relevance_report(context:) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 60 def context_relevance_report(context:, **) score = engine.context_relevance(context: context.to_sym) log.debug('[relevance_theory] context_relevance ' \ "ctx=#{context} score=#{score.round(3)}") { success: true, context: context, relevance: score.round(3) } end |
#most_relevant_inputs(limit: 5) ⇒ Object
54 55 56 57 58 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 54 def most_relevant_inputs(limit: 5, **) inputs = engine.most_relevant(limit: limit) log.debug("[relevance_theory] most_relevant count=#{inputs.size}") { success: true, inputs: inputs.map(&:to_h), count: inputs.size } end |
#relevance_theory_stats ⇒ Object
81 82 83 84 85 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 81 def relevance_theory_stats(**) stats = engine.to_h log.debug("[relevance_theory] stats total=#{stats[:total_inputs]}") { success: true }.merge(stats) end |
#strengthen_relevance(input_id:, amount: 0.1) ⇒ Object
36 37 38 39 40 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 36 def strengthen_relevance(input_id:, amount: 0.1, **) result = engine.strengthen_input(input_id: input_id, amount: amount) log.debug("[relevance_theory] strengthen id=#{input_id[0..7]}") result end |
#submit_relevance_input(content:, input_type:, context:, cognitive_effect: nil, processing_effort: nil, effect_type: nil, source_id: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 13 def submit_relevance_input(content:, input_type:, context:, cognitive_effect: nil, processing_effort: nil, effect_type: nil, source_id: nil, **) input = engine.submit_input( content: content, input_type: input_type.to_sym, context: context.to_sym, cognitive_effect: cognitive_effect || Helpers::Constants::DEFAULT_EFFECT, processing_effort: processing_effort || Helpers::Constants::DEFAULT_EFFORT, effect_type: (effect_type || :new_implication).to_sym, source_id: source_id ) log.debug("[relevance_theory] submit id=#{input.id[0..7]} " \ "type=#{input_type} relevance=#{input.normalized_relevance.round(3)}") { success: true, input: input.to_h } end |
#update_relevance_theory ⇒ Object
74 75 76 77 78 79 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 74 def update_relevance_theory(**) engine.decay_all pruned = engine.prune_irrelevant log.debug("[relevance_theory] decay+prune pruned=#{pruned}") { success: true, pruned: pruned } end |
#weaken_relevance(input_id:, amount: 0.1) ⇒ Object
42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 42 def weaken_relevance(input_id:, amount: 0.1, **) result = engine.weaken_input(input_id: input_id, amount: amount) log.debug("[relevance_theory] weaken id=#{input_id[0..7]}") result end |
#worth_processing_report ⇒ Object
48 49 50 51 52 |
# File 'lib/legion/extensions/agentic/attention/relevance_theory/runners/relevance_theory.rb', line 48 def worth_processing_report(**) inputs = engine.worth_processing log.debug("[relevance_theory] worth_processing count=#{inputs.size}") { success: true, inputs: inputs.map(&:to_h), count: inputs.size } end |