mini_embed 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/mini_embed.rb CHANGED
@@ -1,3 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'mini_embed/mini_embed'
4
+
5
+ class MiniEmbed
6
+ # @param text [String] - text to extract embeddings from
7
+ # @param type [Symbol, nil] - :binary or :vector - type of data you want to receive
8
+ # @return [String, <Float>] - type == :binary - binary string, type == :vector - array of floats
9
+ def embeddings(text:, type: :vector)
10
+ binary_data = embed(text: text) # call original C method
11
+
12
+ return binary_data if type == :binary
13
+ return binary_data.unpack('e*') if type == :vector
14
+
15
+ raise ArgumentError, "Unsupported data type: #{type}"
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makapoxa