Class: RubyLLM::Agents::CachedImageAnalysisResult
- Inherits:
-
Object
- Object
- RubyLLM::Agents::CachedImageAnalysisResult
- Defined in:
- lib/ruby_llm/agents/results/image_analysis_result.rb
Overview
Lightweight result for cached analyses
Instance Attribute Summary collapse
-
#analysis_type ⇒ Object
readonly
Returns the value of attribute analysis_type.
-
#cached_at ⇒ Object
readonly
Returns the value of attribute cached_at.
-
#caption ⇒ Object
readonly
Returns the value of attribute caption.
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#model_id ⇒ Object
readonly
Returns the value of attribute model_id.
-
#objects ⇒ Object
readonly
Returns the value of attribute objects.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#total_cost ⇒ Object
readonly
Returns the value of attribute total_cost.
Instance Method Summary collapse
- #batch? ⇒ Boolean
- #cached? ⇒ Boolean
- #caption? ⇒ Boolean
- #colors? ⇒ Boolean
- #count ⇒ Object
- #description? ⇒ Boolean
- #dominant_color ⇒ Object
- #error? ⇒ Boolean
-
#initialize(data) ⇒ CachedImageAnalysisResult
constructor
A new instance of CachedImageAnalysisResult.
- #objects? ⇒ Boolean
- #single? ⇒ Boolean
- #success? ⇒ Boolean
- #tag_symbols ⇒ Object
- #tags? ⇒ Boolean
- #text? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ CachedImageAnalysisResult
Returns a new instance of CachedImageAnalysisResult.
259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 259 def initialize(data) @image = data[:image] @model_id = data[:model_id] @analysis_type = data[:analysis_type] @caption = data[:caption] @description = data[:description] @tags = data[:tags] || [] @objects = data[:objects] || [] @colors = data[:colors] || [] @text = data[:text] @total_cost = data[:total_cost] @cached_at = data[:cached_at] end |
Instance Attribute Details
#analysis_type ⇒ Object (readonly)
Returns the value of attribute analysis_type.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def analysis_type @analysis_type end |
#cached_at ⇒ Object (readonly)
Returns the value of attribute cached_at.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def cached_at @cached_at end |
#caption ⇒ Object (readonly)
Returns the value of attribute caption.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def caption @caption end |
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def colors @colors end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def description @description end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def image @image end |
#model_id ⇒ Object (readonly)
Returns the value of attribute model_id.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def model_id @model_id end |
#objects ⇒ Object (readonly)
Returns the value of attribute objects.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def objects @objects end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def @tags end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def text @text end |
#total_cost ⇒ Object (readonly)
Returns the value of attribute total_cost.
255 256 257 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 255 def total_cost @total_cost end |
Instance Method Details
#batch? ⇒ Boolean
293 294 295 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 293 def batch? false end |
#cached? ⇒ Boolean
281 282 283 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 281 def cached? true end |
#caption? ⇒ Boolean
297 298 299 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 297 def caption? caption.present? end |
#colors? ⇒ Boolean
313 314 315 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 313 def colors? colors.any? end |
#count ⇒ Object
285 286 287 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 285 def count success? ? 1 : 0 end |
#description? ⇒ Boolean
301 302 303 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 301 def description? description.present? end |
#dominant_color ⇒ Object
325 326 327 328 329 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 325 def dominant_color return nil unless colors? colors.max_by { |c| c[:percentage] || 0 } end |
#error? ⇒ Boolean
277 278 279 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 277 def error? !success? end |
#objects? ⇒ Boolean
309 310 311 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 309 def objects? objects.any? end |
#single? ⇒ Boolean
289 290 291 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 289 def single? true end |
#success? ⇒ Boolean
273 274 275 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 273 def success? caption.present? || description.present? || .any? end |
#tag_symbols ⇒ Object
321 322 323 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 321 def tag_symbols .map { |t| t.to_s.downcase.gsub(/\s+/, "_").to_sym } end |
#tags? ⇒ Boolean
305 306 307 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 305 def .any? end |
#text? ⇒ Boolean
317 318 319 |
# File 'lib/ruby_llm/agents/results/image_analysis_result.rb', line 317 def text? text.present? end |