Class: Ragents::Workflow
- Inherits:
-
Object
- Object
- Ragents::Workflow
- Defined in:
- lib/ragents/orchestrator.rb
Overview
Workflow builder for sequential agent execution
Instance Method Summary collapse
-
#execute ⇒ Context
Execute all steps sequentially.
-
#initialize(orchestrator) ⇒ Workflow
constructor
A new instance of Workflow.
-
#step(name, **options) {|Context| ... } ⇒ Object
Add a step to the workflow.
Constructor Details
#initialize(orchestrator) ⇒ Workflow
Returns a new instance of Workflow.
138 139 140 141 142 |
# File 'lib/ragents/orchestrator.rb', line 138 def initialize(orchestrator) @orchestrator = orchestrator @steps = [] @current_context = nil end |
Instance Method Details
#execute ⇒ Context
Execute all steps sequentially
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/ragents/orchestrator.rb', line 155 def execute @steps.each do |step| opts = step[:options].dup # If a block is provided, call it with current context to get dynamic options if step[:block] && @current_context dynamic_opts = step[:block].call(@current_context) opts = opts.merge(dynamic_opts) if dynamic_opts.is_a?(Hash) end # Pass the previous context to maintain conversation flow opts[:context] = @current_context if @current_context && !opts.key?(:context) @current_context = @orchestrator.run(step[:name], **opts) end @current_context end |
#step(name, **options) {|Context| ... } ⇒ Object
Add a step to the workflow
148 149 150 151 |
# File 'lib/ragents/orchestrator.rb', line 148 def step(name, **, &block) @steps << { name: name, options: , block: block } self end |