Class: ComposableAgents::RubyAgent
- Defined in:
- lib/composable_agents/ruby_agent.rb
Overview
Agent implementation that wraps a Ruby Proc for custom logic
This agent allows wrapping arbitrary Ruby logic as an Agent by providing a Proc that handles the transformation of input artifacts to output artifacts.
Instance Attribute Summary
Attributes inherited from Agent
Public API collapse
-
#initialize(processor, *args, **kwargs) ⇒ RubyAgent
constructor
Initialize a new RubyAgent with a processing proc.
-
#run(**input_artifacts) ⇒ Hash{Symbol => Object}
Execute the agent to generate some output artifacts based on some input artifacts.
Methods inherited from Agent
Methods included from Mixins::Logger
Constructor Details
#initialize(processor, *args, **kwargs) ⇒ RubyAgent
Initialize a new RubyAgent with a processing proc
15 16 17 18 |
# File 'lib/composable_agents/ruby_agent.rb', line 15 def initialize(processor, *args, **kwargs) super(*args, **kwargs) @processor = processor end |
Instance Method Details
#run(**input_artifacts) ⇒ Hash{Symbol => Object}
Execute the agent to generate some output artifacts based on some input artifacts.
24 25 26 |
# File 'lib/composable_agents/ruby_agent.rb', line 24 def run(**input_artifacts) @processor.call(input_artifacts) end |