Module: RubyLLM::Agents::ImageUpscaler::Execution

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

Overview

Execution logic for image upscalers

Handles image validation, budget tracking, caching, upscaling execution, and result building.

Instance Method Summary collapse

Instance Method Details

#executeImageUpscaleResult

Execute the image upscaling 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/upscaler/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(ImageUpscaleResult) if cache_enabled?
  return cached if cached

  # Upscale image
  upscaled_image = upscale_image

  # Build result
  result = build_result(
    image: upscaled_image,
    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