Module: RubyLLM::Agents::ImagePipeline::DSL
- Defined in:
- lib/ruby_llm/agents/image/pipeline/dsl.rb
Overview
DSL for defining image pipeline steps and configuration
Provides methods for configuring pipeline steps, callbacks, caching, and error handling behavior.
Instance Method Summary collapse
-
#after_pipeline(method_name = nil) { ... } ⇒ void
Add a callback to run after the pipeline.
-
#before_pipeline(method_name = nil) { ... } ⇒ void
Add a callback to run before the pipeline.
-
#cache_enabled? ⇒ Boolean
Check if caching is enabled.
-
#cache_for(ttl) ⇒ Object
Enable caching with the given TTL.
-
#cache_ttl ⇒ ActiveSupport::Duration, ...
Get the cache TTL.
-
#callbacks ⇒ Hash
Get callbacks.
-
#description(value = nil) ⇒ String?
Set or get the description.
-
#step(name, **config) ⇒ void
Define a pipeline step.
-
#steps ⇒ Array<Hash>
Get all defined steps.
-
#stop_on_error(value = nil) ⇒ Boolean
(also: #stop_on_error?)
Set whether to stop on error (default: true).
Instance Method Details
#after_pipeline(method_name = nil) { ... } ⇒ void
This method returns an undefined value.
Add a callback to run after the pipeline
93 94 95 96 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 93 def after_pipeline(method_name = nil, &block) @callbacks ||= {before: [], after: []} @callbacks[:after] << (block || method_name) end |
#before_pipeline(method_name = nil) { ... } ⇒ void
This method returns an undefined value.
Add a callback to run before the pipeline
78 79 80 81 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 78 def before_pipeline(method_name = nil, &block) @callbacks ||= {before: [], after: []} @callbacks[:before] << (block || method_name) end |
#cache_enabled? ⇒ Boolean
Check if caching is enabled
134 135 136 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 134 def cache_enabled? !cache_ttl.nil? end |
#cache_for(ttl) ⇒ Object
Enable caching with the given TTL
120 121 122 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 120 def cache_for(ttl) @cache_ttl = ttl end |
#cache_ttl ⇒ ActiveSupport::Duration, ...
Get the cache TTL
127 128 129 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 127 def cache_ttl @cache_ttl || inherited_or_default(:cache_ttl, nil) end |
#callbacks ⇒ Hash
Get callbacks
101 102 103 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 101 def callbacks @callbacks ||= {before: [], after: []} end |
#description(value = nil) ⇒ String?
Set or get the description
109 110 111 112 113 114 115 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 109 def description(value = nil) if value @description = value else @description || inherited_or_default(:description, nil) end end |
#step(name, **config) ⇒ void
This method returns an undefined value.
Define a pipeline step
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 48 def step(name, **config) @steps ||= [] # Validate step configuration validate_step_config!(name, config) @steps << { name: name, config: config, type: determine_step_type(config) } end |
#steps ⇒ Array<Hash>
Get all defined steps
64 65 66 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 64 def steps @steps ||= [] end |
#stop_on_error(value = nil) ⇒ Boolean Also known as: stop_on_error?
Set whether to stop on error (default: true)
142 143 144 145 146 147 148 149 |
# File 'lib/ruby_llm/agents/image/pipeline/dsl.rb', line 142 def stop_on_error(value = nil) if value.nil? return @stop_on_error if defined?(@stop_on_error) && !@stop_on_error.nil? inherited_or_default(:stop_on_error, true) else @stop_on_error = value end end |