Class: RubyLLM::Agents::CachedImageTransformResult

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/agents/results/image_transform_result.rb

Overview

Lightweight result for cached transformations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CachedImageTransformResult

Returns a new instance of CachedImageTransformResult.



221
222
223
224
225
226
227
228
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 221

def initialize(data)
  @urls = data[:urls] || []
  @datas = data[:datas] || []
  @mime_type = data[:mime_type]
  @model_id = data[:model_id]
  @total_cost = data[:total_cost]
  @cached_at = data[:cached_at]
end

Instance Attribute Details

#cached_atObject (readonly)

Returns the value of attribute cached_at.



219
220
221
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 219

def cached_at
  @cached_at
end

#datasObject (readonly)

Returns the value of attribute datas.



219
220
221
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 219

def datas
  @datas
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



219
220
221
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 219

def mime_type
  @mime_type
end

#model_idObject (readonly)

Returns the value of attribute model_id.



219
220
221
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 219

def model_id
  @model_id
end

#total_costObject (readonly)

Returns the value of attribute total_cost.



219
220
221
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 219

def total_cost
  @total_cost
end

#urlsObject (readonly)

Returns the value of attribute urls.



219
220
221
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 219

def urls
  @urls
end

Instance Method Details

#base64?Boolean

Returns:

  • (Boolean)


250
251
252
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 250

def base64?
  datas.any?
end

#batch?Boolean

Returns:

  • (Boolean)


262
263
264
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 262

def batch?
  count > 1
end

#cached?Boolean

Returns:

  • (Boolean)


238
239
240
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 238

def cached?
  true
end

#countObject



254
255
256
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 254

def count
  [urls.size, datas.size].max
end

#dataObject



246
247
248
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 246

def data
  datas.first
end

#error?Boolean

Returns:

  • (Boolean)


234
235
236
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 234

def error?
  !success?
end

#single?Boolean

Returns:

  • (Boolean)


258
259
260
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 258

def single?
  count == 1
end

#success?Boolean

Returns:

  • (Boolean)


230
231
232
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 230

def success?
  urls.any? || datas.any?
end

#urlObject



242
243
244
# File 'lib/ruby_llm/agents/results/image_transform_result.rb', line 242

def url
  urls.first
end