Class: Phronomy::MultiAgent::TeamCoordinator
- Inherits:
-
Object
- Object
- Phronomy::MultiAgent::TeamCoordinator
- Defined in:
- lib/phronomy/multi_agent/team_coordinator.rb
Overview
Coordinator/worker multi-agent pattern with persistent worker Agent state.
Class Method Summary collapse
- ._aggregator ⇒ Object
- ._coordinator_instructions ⇒ Object
- ._coordinator_model ⇒ Object
- ._coordinator_provider ⇒ Object
- ._on_error ⇒ Object
- ._pool_size ⇒ Object
- ._scheduler ⇒ Object
- ._worker_agent ⇒ Object
- .aggregate(&block) ⇒ Object
- .coordinator_instructions(value = nil) ⇒ Object
- .coordinator_model(value = nil) ⇒ Object
- .coordinator_provider(value = nil) ⇒ Object
- .pool(size:, agent:, on_error: :raise) ⇒ Object
- .schedule(&block) ⇒ Object
Instance Method Summary collapse
Class Method Details
._aggregator ⇒ Object
59 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 59 def _aggregator = @aggregator |
._coordinator_instructions ⇒ Object
53 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 53 def _coordinator_instructions = @coordinator_instructions |
._coordinator_model ⇒ Object
52 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 52 def _coordinator_model = @coordinator_model |
._coordinator_provider ⇒ Object
54 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 54 def _coordinator_provider = @coordinator_provider |
._on_error ⇒ Object
57 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 57 def _on_error = @on_error || :raise |
._pool_size ⇒ Object
55 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 55 def _pool_size = @pool_size || 1 |
._scheduler ⇒ Object
58 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 58 def _scheduler = @scheduler |
._worker_agent ⇒ Object
56 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 56 def _worker_agent = @worker_agent |
.aggregate(&block) ⇒ Object
48 49 50 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 48 def aggregate(&block) @aggregator = block end |
.coordinator_instructions(value = nil) ⇒ Object
26 27 28 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 26 def coordinator_instructions(value = nil) value ? @coordinator_instructions = value : @coordinator_instructions end |
.coordinator_model(value = nil) ⇒ Object
21 22 23 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 21 def coordinator_model(value = nil) value ? @coordinator_model = value : @coordinator_model end |
.coordinator_provider(value = nil) ⇒ Object
31 32 33 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 31 def coordinator_provider(value = nil) value ? @coordinator_provider = value : @coordinator_provider end |
.pool(size:, agent:, on_error: :raise) ⇒ Object
36 37 38 39 40 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 36 def pool(size:, agent:, on_error: :raise) @pool_size = Integer(size) @worker_agent = agent @on_error = on_error end |
.schedule(&block) ⇒ Object
43 44 45 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 43 def schedule(&block) @scheduler = block end |
Instance Method Details
#invoke(team_input, config: {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 63 def invoke(team_input, config: {}) unless self.class._worker_agent raise ArgumentError, "pool :agent must be configured before invoking" end task_queue = [] run_coordinator(team_input, task_queue) assignments = run_workers(task_queue) finalize_result(assignments) end |
#stream(team_input, config: {}, &block) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/phronomy/multi_agent/team_coordinator.rb', line 75 def stream(team_input, config: {}, &block) return invoke(team_input, config: config) unless block unless self.class._worker_agent raise ArgumentError, "pool :agent must be configured before invoking" end task_queue = [] run_coordinator(team_input, task_queue) assignments = run_workers(task_queue, &block) finalize_result(assignments) end |