Module: RubyLLM::Agents::ImageTransformer::DSL
- Includes:
- Concerns::ImageOperationDSL
- Defined in:
- lib/ruby_llm/agents/image/transformer/dsl.rb
Overview
DSL for configuring image transformers
Provides class-level methods to configure model, strength, and other image transformation parameters.
Instance Method Summary collapse
-
#guidance_scale(value = nil) ⇒ Float?
Set or get guidance scale (CFG scale).
-
#negative_prompt(value = nil) ⇒ String?
Set or get negative prompt.
-
#preserve_composition(value = nil) ⇒ Boolean
Set or get whether to preserve composition.
-
#size(value = nil) ⇒ String
Set or get the output image size.
-
#steps(value = nil) ⇒ Integer?
Set or get number of inference steps.
-
#strength(value = nil) ⇒ Float
Set or get the transformation strength.
-
#template(value = nil) ⇒ String?
Set a prompt template (use #prompt as placeholder).
-
#template_string ⇒ String?
Get the template string.
Methods included from Concerns::ImageOperationDSL
#cache_enabled?, #cache_for, #cache_ttl, #description, #model
Instance Method Details
#guidance_scale(value = nil) ⇒ Float?
Set or get guidance scale (CFG scale)
107 108 109 110 111 112 113 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 107 def guidance_scale(value = nil) if value @guidance_scale = value else @guidance_scale || inherited_or_default(:guidance_scale, nil) end end |
#negative_prompt(value = nil) ⇒ String?
Set or get negative prompt
95 96 97 98 99 100 101 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 95 def negative_prompt(value = nil) if value @negative_prompt = value else @negative_prompt || inherited_or_default(:negative_prompt, nil) end end |
#preserve_composition(value = nil) ⇒ Boolean
Set or get whether to preserve composition
When true, maintains the overall structure and layout of the original image.
62 63 64 65 66 67 68 69 70 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 62 def preserve_composition(value = nil) if value.nil? result = @preserve_composition result = inherited_or_default(:preserve_composition, true) if result.nil? result else @preserve_composition = value end end |
#size(value = nil) ⇒ String
Set or get the output image size
28 29 30 31 32 33 34 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 28 def size(value = nil) if value @size = value else @size || inherited_or_default(:size, config.default_image_size) end end |
#steps(value = nil) ⇒ Integer?
Set or get number of inference steps
119 120 121 122 123 124 125 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 119 def steps(value = nil) if value @steps = value else @steps || inherited_or_default(:steps, nil) end end |
#strength(value = nil) ⇒ Float
Set or get the transformation strength
Controls how much the image is transformed (0.0-1.0). Lower values preserve more of the original image. Higher values allow more creative freedom.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 44 def strength(value = nil) if value unless value.is_a?(Numeric) && value.between?(0.0, 1.0) raise ArgumentError, "Strength must be between 0.0 and 1.0" end @strength = value.to_f else @strength || inherited_or_default(:strength, 0.75) end end |
#template(value = nil) ⇒ String?
Set a prompt template (use RubyLLM::Agents::ImageTransformer#prompt as placeholder)
76 77 78 79 80 81 82 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 76 def template(value = nil) if value @template_string = value else @template_string || inherited_or_default(:template_string, nil) end end |
#template_string ⇒ String?
Get the template string
87 88 89 |
# File 'lib/ruby_llm/agents/image/transformer/dsl.rb', line 87 def template_string @template_string || inherited_or_default(:template_string, nil) end |