Class: Langchain::Utils::ImageWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/langchain/utils/image_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_url) ⇒ ImageWrapper

Returns a new instance of ImageWrapper.



11
12
13
# File 'lib/langchain/utils/image_wrapper.rb', line 11

def initialize(image_url)
  @image_url = image_url
end

Instance Attribute Details

#image_urlObject (readonly)

Returns the value of attribute image_url.



9
10
11
# File 'lib/langchain/utils/image_wrapper.rb', line 9

def image_url
  @image_url
end

Instance Method Details

#base64Object



15
16
17
18
19
20
# File 'lib/langchain/utils/image_wrapper.rb', line 15

def base64
  @base64 ||= begin
    image_data = open_image.read
    Base64.strict_encode64(image_data)
  end
end

#mime_typeObject



22
23
24
25
# File 'lib/langchain/utils/image_wrapper.rb', line 22

def mime_type
  # TODO: Make it work with local files
  open_image.meta["content-type"]
end