Class: Noiseless::AST::ImageQuery

Inherits:
Node
  • Object
show all
Defined in:
lib/noiseless/ast/image_query.rb

Overview

Image search node for Typesense visual search Supports searching by image URL or base64 encoded image data

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#to_h

Constructor Details

#initialize(field, image_data, k: 10) ⇒ ImageQuery

Returns a new instance of ImageQuery.

Parameters:

  • field (Symbol, String)

    The image embedding field name

  • image_data (String)

    Image URL or base64 encoded image data

  • k (Integer) (defaults to: 10)

    Number of nearest neighbors (default: 10)



13
14
15
16
17
18
# File 'lib/noiseless/ast/image_query.rb', line 13

def initialize(field, image_data, k: 10)
  super()
  @field = field
  @image_data = image_data
  @k = k
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



8
9
10
# File 'lib/noiseless/ast/image_query.rb', line 8

def field
  @field
end

#image_dataObject (readonly)

Returns the value of attribute image_data.



8
9
10
# File 'lib/noiseless/ast/image_query.rb', line 8

def image_data
  @image_data
end

#kObject (readonly)

Returns the value of attribute k.



8
9
10
# File 'lib/noiseless/ast/image_query.rb', line 8

def k
  @k
end

Instance Method Details

#base64?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/noiseless/ast/image_query.rb', line 24

def base64?
  !url?
end

#url?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/noiseless/ast/image_query.rb', line 20

def url?
  @image_data.start_with?("http://", "https://")
end