openai-client 0.4.1 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fdb9832b6b6a5b14a1b14537ac74595fa1a85a689f84fc7f2411651812b6131
4
- data.tar.gz: 57d4465e713d0ff02e7c5b97dcc32b3db7e96085b3850d00a4076eb2de8509ae
3
+ metadata.gz: be7dc55119b7220165c1025d64ddf0f9a9f4a05efb79f4ffd03fece3c7cd60be
4
+ data.tar.gz: 591cdc0fe81065d49db7907a0b9f740a17962744cdb9cc3ecdf1b9d40967c50e
5
5
  SHA512:
6
- metadata.gz: 78fb79a3c56a1ad02ac6574f619dc8c5492b30d167478b5678730768e40b1c91adccebebceb238440a51915337d331472de8de9b711133d4276fd49066a33123
7
- data.tar.gz: bd23759e786d446ed0e14ad63b7db1e4b438f5b7291cb68ec97b38928e00e3be38e73664909f3c6837c0b7391154f317ef45b23e95628cef5fe35fc97c955742
6
+ metadata.gz: 8d6f2dc7fa5cc014cf77a2defd2e0efce3f6da336612d3812c9b7df74befba4fc9a069c24c2491d16fc518fd22b985422d6a9c7e06f63c217728d70a6caf4eb4
7
+ data.tar.gz: ba737dc9d234a49fb20afc98223354dee5a66f1efbac4d95df3b0676b0a8cad95688fbd1b4c38a49d24f5fe8f9001269b33596b03b7fd979aaaa1c39225e300b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openai-client (0.4.1)
4
+ openai-client (0.5.0)
5
5
  faraday (~> 1.8)
6
6
  faraday_middleware (~> 1.2)
7
7
 
data/README.md CHANGED
@@ -11,8 +11,7 @@ This gem is a wrapper for calling the OpenAI and GPT-3 APIs.
11
11
  * [Create an Image](#create-an-image)
12
12
  * [Create an Image Edit](#create-an-image-edit)
13
13
  * [Create an Image Variation](#create-an-image-variation)
14
-
15
-
14
+ * [OpenAI Embeddings API](#openai-embeddings-api)
16
15
 
17
16
  ## Installation
18
17
 
@@ -141,6 +140,18 @@ response = Openai::Client.images.variations(request_body)
141
140
 
142
141
  [Request body documentation](https://platform.openai.com/docs/api-reference/images/create-variation)
143
142
 
143
+ ## OpenAI Embeddings API
144
+
145
+ ```ruby
146
+ request_body = {
147
+ model: 'text-embedding-ada-002',
148
+ input: 'The food was delicious and the waiter...'
149
+ }
150
+ Openai::Client.embeddings.create(request_body)
151
+ ```
152
+
153
+ [Request body documentation](https://platform.openai.com/docs/api-reference/embeddings/create)
154
+
144
155
  ## Contributing
145
156
 
146
157
  Bug reports and pull requests are welcome on GitHub at <https://github.com/itikhonenko/openai-client>.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openai
4
+ module Client
5
+ class Embeddings
6
+ PATH = 'embeddings'
7
+
8
+ # @api public
9
+ # Public: Makes an API call to create an embedding.
10
+ #
11
+ # @param [Hash] body request body
12
+ #
13
+ # @return [Hash] an embedding
14
+ def create(body)
15
+ Http.new.post(PATH, body).body
16
+ rescue Faraday::Error
17
+ nil
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Openai
4
4
  module Client
5
- VERSION = '0.4.1'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
data/lib/openai/client.rb CHANGED
@@ -12,12 +12,13 @@ require 'openai/client/models'
12
12
  require 'openai/client/edits'
13
13
  require 'openai/client/completions'
14
14
  require 'openai/client/images'
15
+ require 'openai/client/embeddings'
15
16
 
16
17
  module Openai
17
18
  module Client
18
19
  extend Configurable
19
20
 
20
- ATTRS = ['models', 'edits', 'completions', 'images'].freeze
21
+ ATTRS = ['models', 'edits', 'completions', 'images', 'embeddings'].freeze
21
22
 
22
23
  class << self
23
24
  ATTRS.each do |attr|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ihor Tykhonenko
@@ -58,6 +58,7 @@ files:
58
58
  - lib/openai/client/configurable.rb
59
59
  - lib/openai/client/configuration.rb
60
60
  - lib/openai/client/edits.rb
61
+ - lib/openai/client/embeddings.rb
61
62
  - lib/openai/client/http.rb
62
63
  - lib/openai/client/images.rb
63
64
  - lib/openai/client/models.rb