Module: RubyLLM::Agents::ImageVariator::Execution

Includes:
Concerns::ImageOperationExecution
Included in:
RubyLLM::Agents::ImageVariator
Defined in:
lib/ruby_llm/agents/image/variator/execution.rb

Overview

Execution logic for image variators

Handles image validation, budget tracking, caching, variation generation, and result building.

Instance Method Summary collapse

Instance Method Details

#executeImageVariationResult

Execute the image variation pipeline

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ruby_llm/agents/image/variator/execution.rb', line 20

def execute
  started_at = Time.current

  resolve_tenant_context!
  check_budget! if budget_tracking_enabled?
  validate_image!

  # Check cache
  cached = check_cache(ImageVariationResult) if cache_enabled?
  return cached if cached

  # Generate variations
  variations = generate_variations

  # Build result
  result = build_result(
    images: variations,
    started_at: started_at,
    completed_at: Time.current
  )

  # Cache result
  write_cache(result) if cache_enabled?

  # Track execution
  record_execution(result) if execution_tracking_enabled?

  result
rescue => e
  record_failed_execution(e, started_at) if execution_tracking_enabled?
  build_error_result(e, started_at)
end