Module: RubyLLM::Agents::Concerns::ImageOperationDSL

Included in:
BackgroundRemover::DSL, ImageAnalyzer::DSL, ImageEditor::DSL, ImageTransformer::DSL, ImageUpscaler::DSL, ImageVariator::DSL
Defined in:
lib/ruby_llm/agents/image/concerns/image_operation_dsl.rb

Overview

Shared DSL methods for all image operation classes

Provides common configuration options like model, description, and caching that are shared across ImageVariator, ImageEditor, ImageTransformer, and ImageUpscaler.

Instance Method Summary collapse

Instance Method Details

#cache_enabled?Boolean

Check if caching is enabled

Returns:

  • (Boolean)

    true if caching is enabled



54
55
56
# File 'lib/ruby_llm/agents/image/concerns/image_operation_dsl.rb', line 54

def cache_enabled?
  !cache_ttl.nil?
end

#cache_for(ttl) ⇒ Object

Enable caching with the given TTL

Parameters:

  • ttl (ActiveSupport::Duration, Integer)

    Cache duration



40
41
42
# File 'lib/ruby_llm/agents/image/concerns/image_operation_dsl.rb', line 40

def cache_for(ttl)
  @cache_ttl = ttl
end

#cache_ttlActiveSupport::Duration, ...

Get the cache TTL

Returns:

  • (ActiveSupport::Duration, Integer, nil)

    The cache TTL



47
48
49
# File 'lib/ruby_llm/agents/image/concerns/image_operation_dsl.rb', line 47

def cache_ttl
  @cache_ttl || inherited_or_default(:cache_ttl, nil)
end

#description(value = nil) ⇒ String?

Set or get the description

Parameters:

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

    Description

Returns:

  • (String, nil)

    The description



29
30
31
32
33
34
35
# File 'lib/ruby_llm/agents/image/concerns/image_operation_dsl.rb', line 29

def description(value = nil)
  if value
    @description = value
  else
    @description || inherited_or_default(:description, nil)
  end
end

#model(value = nil) ⇒ String

Set or get the model

Parameters:

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

    Model identifier

Returns:

  • (String)

    The model to use



17
18
19
20
21
22
23
# File 'lib/ruby_llm/agents/image/concerns/image_operation_dsl.rb', line 17

def model(value = nil)
  if value
    @model = value
  else
    @model || inherited_or_default(:model, default_model)
  end
end