Module: Legion::Extensions::Agentic::Attention::Switching::Runners::AttentionSwitching
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb
Instance Method Summary collapse
- #active_task(engine: nil) ⇒ Object
- #average_switch_cost(engine: nil) ⇒ Object
- #decay_residuals(engine: nil) ⇒ Object
- #recent_switches(limit: 10, engine: nil) ⇒ Object
- #register_task(name:, task_type: :analytical, complexity: 0.5, engine: nil) ⇒ Object
- #residual_tasks(engine: nil) ⇒ Object
- #status(engine: nil) ⇒ Object
- #switch_cost_between(from_id:, to_id:, engine: nil) ⇒ Object
- #switch_to(task_id:, engine: nil) ⇒ Object
- #switching_report(engine: nil) ⇒ Object
- #warmup(engine: nil) ⇒ Object
Instance Method Details
#active_task(engine: nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 40 def active_task(engine: nil, **) eng = engine || default_engine task = eng.active_task return { success: false, error: 'no active task' } unless task { success: true, task: task.to_h } end |
#average_switch_cost(engine: nil) ⇒ Object
58 59 60 61 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 58 def average_switch_cost(engine: nil, **) eng = engine || default_engine { success: true, average_cost: eng.average_switch_cost } end |
#decay_residuals(engine: nil) ⇒ Object
34 35 36 37 38 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 34 def decay_residuals(engine: nil, **) eng = engine || default_engine result = eng.decay_all_residuals! { success: true, **result } end |
#recent_switches(limit: 10, engine: nil) ⇒ Object
53 54 55 56 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 53 def recent_switches(limit: 10, engine: nil, **) eng = engine || default_engine { success: true, switches: eng.recent_switches(limit: limit).map(&:to_h) } end |
#register_task(name:, task_type: :analytical, complexity: 0.5, engine: nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 12 def register_task(name:, task_type: :analytical, complexity: 0.5, engine: nil, **) eng = engine || default_engine task = eng.register_task(name: name, task_type: task_type, complexity: complexity) { success: true, task: task.to_h } end |
#residual_tasks(engine: nil) ⇒ Object
48 49 50 51 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 48 def residual_tasks(engine: nil, **) eng = engine || default_engine { success: true, tasks: eng.tasks_with_residual.map(&:to_h) } end |
#status(engine: nil) ⇒ Object
76 77 78 79 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 76 def status(engine: nil, **) eng = engine || default_engine { success: true, **eng.to_h } end |
#switch_cost_between(from_id:, to_id:, engine: nil) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 63 def switch_cost_between(from_id:, to_id:, engine: nil, **) eng = engine || default_engine cost = eng.switch_cost_between(from_id: from_id, to_id: to_id) return { success: false, error: 'no switches found for this pair' } unless cost { success: true, cost: cost } end |
#switch_to(task_id:, engine: nil) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 18 def switch_to(task_id:, engine: nil, **) eng = engine || default_engine result = eng.switch_to(task_id: task_id) return { success: false, error: 'task not found' } unless result { success: true, **result } end |
#switching_report(engine: nil) ⇒ Object
71 72 73 74 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 71 def switching_report(engine: nil, **) eng = engine || default_engine { success: true, report: eng.switching_report } end |
#warmup(engine: nil) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/attention/switching/runners/attention_switching.rb', line 26 def warmup(engine: nil, **) eng = engine || default_engine task = eng.warmup_active return { success: false, error: 'no active task' } unless task { success: true, task: task.to_h } end |