Class: RubyLLM::Agents::CachedImageVariationResult

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

Overview

Lightweight result for cached variations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CachedImageVariationResult

Returns a new instance of CachedImageVariationResult.



207
208
209
210
211
212
213
214
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 207

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.



205
206
207
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 205

def cached_at
  @cached_at
end

#datasObject (readonly)

Returns the value of attribute datas.



205
206
207
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 205

def datas
  @datas
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



205
206
207
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 205

def mime_type
  @mime_type
end

#model_idObject (readonly)

Returns the value of attribute model_id.



205
206
207
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 205

def model_id
  @model_id
end

#total_costObject (readonly)

Returns the value of attribute total_cost.



205
206
207
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 205

def total_cost
  @total_cost
end

#urlsObject (readonly)

Returns the value of attribute urls.



205
206
207
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 205

def urls
  @urls
end

Instance Method Details

#base64?Boolean

Returns:

  • (Boolean)


236
237
238
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 236

def base64?
  datas.any?
end

#batch?Boolean

Returns:

  • (Boolean)


248
249
250
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 248

def batch?
  count > 1
end

#cached?Boolean

Returns:

  • (Boolean)


224
225
226
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 224

def cached?
  true
end

#countObject



240
241
242
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 240

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

#dataObject



232
233
234
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 232

def data
  datas.first
end

#error?Boolean

Returns:

  • (Boolean)


220
221
222
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 220

def error?
  !success?
end

#single?Boolean

Returns:

  • (Boolean)


244
245
246
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 244

def single?
  count == 1
end

#success?Boolean

Returns:

  • (Boolean)


216
217
218
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 216

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

#urlObject



228
229
230
# File 'lib/ruby_llm/agents/results/image_variation_result.rb', line 228

def url
  urls.first
end