Module: RubyLLM::Agents::ImageVariator::DSL

Includes:
Concerns::ImageOperationDSL
Defined in:
lib/ruby_llm/agents/image/variator/dsl.rb

Overview

DSL for configuring image variators

Provides class-level methods to configure model, size, variation strength, and other image variation parameters.

Examples:

class LogoVariator < RubyLLM::Agents::ImageVariator
  model "gpt-image-1"
  size "1024x1024"
  variation_strength 0.3
  cache_for 1.hour
end

Instance Method Summary collapse

Methods included from Concerns::ImageOperationDSL

#cache_enabled?, #cache_for, #cache_ttl, #description, #model

Instance Method Details

#size(value = nil) ⇒ String

Set or get the output image size

Parameters:

  • value (String, nil) (defaults to: nil)

    Size (e.g., “1024x1024”)

Returns:

  • (String)

    The size to use



28
29
30
31
32
33
34
# File 'lib/ruby_llm/agents/image/variator/dsl.rb', line 28

def size(value = nil)
  if value
    @size = value
  else
    @size || inherited_or_default(:size, config.default_image_size)
  end
end

#variation_strength(value = nil) ⇒ Float

Set or get the variation strength

Controls how different variations should be from the original. Higher values produce more diverse variations.

Parameters:

  • value (Float, nil) (defaults to: nil)

    Strength (0.0-1.0)

Returns:

  • (Float)

    The variation strength



43
44
45
46
47
48
49
50
51
52
# File 'lib/ruby_llm/agents/image/variator/dsl.rb', line 43

def variation_strength(value = nil)
  if value
    unless value.is_a?(Numeric) && value.between?(0.0, 1.0)
      raise ArgumentError, "Variation strength must be between 0.0 and 1.0"
    end
    @variation_strength = value.to_f
  else
    @variation_strength || inherited_or_default(:variation_strength, 0.5)
  end
end