Module: RubyLLM::Agents::ImageAnalyzer::Execution

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

Overview

Execution logic for image analyzers

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

Instance Method Summary collapse

Instance Method Details

#executeImageAnalysisResult

Execute the image analysis pipeline

Returns:



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
52
# File 'lib/ruby_llm/agents/image/analyzer/execution.rb', line 21

def execute
  started_at = Time.current

  resolve_tenant_context!
  check_budget! if budget_tracking_enabled?
  validate_image!

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

  # Analyze image
  analysis_data = analyze_image

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