Class: Langchain::Utils::ImageWrapper
- Inherits:
-
Object
- Object
- Langchain::Utils::ImageWrapper
- Defined in:
- lib/langchain/utils/image_wrapper.rb
Instance Attribute Summary collapse
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
Instance Method Summary collapse
- #base64 ⇒ Object
-
#initialize(image_url) ⇒ ImageWrapper
constructor
A new instance of ImageWrapper.
- #mime_type ⇒ Object
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_url ⇒ Object (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
#base64 ⇒ Object
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_type ⇒ Object
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.["content-type"] end |