openai-client 0.2.1 → 0.3.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: beca324f47af00b9a3783c51af2b17c37ffe9334ab604e0843f2c07d6b637014
4
- data.tar.gz: fe550ad70a671ffd2b1bb7dfecdfbbeffa303f6b5201ce6379e1b663230bebd5
3
+ metadata.gz: 374775f26834baae35b6799f23ebc4c1f82379292c7b67fb0529a85a3dbee23b
4
+ data.tar.gz: 00a67ee196ac3f0b6e52f377605c76273c968d3aec03a47820f75ed6955907eb
5
5
  SHA512:
6
- metadata.gz: cc43ebb61aaf697ba274b39dd838a30c6d79c1fe4e46a3618e49c0f2a82ae0d8809c26ce3ac6d8835d260be73487883d53c1842385cddc098eadd4ba44d2e0a0
7
- data.tar.gz: 8fb583dacd100893af86455720c121450bd574af12f5afd7f4bd1f3b21da14461ea5fca0ee4a4a4f402ca8fb197f8c0ef5359c99d46d45222d0abadb55d634d0
6
+ metadata.gz: ddd4d92869f64c240c45924ea43b6b9acda29ec97f57c5e3f54d5b5602ec4b43e754247b53407758c20fa10abb54a8399324a59e85437d0869bd4f4e6c448a36
7
+ data.tar.gz: 24ec9056e95a781ed5d0f6c18c205738a375b3fb990168f41f6a1be6fec34769772403fff93d531b900d67be217a0acc6c6ff84737ef54a47dd4f23956c84354
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openai-client (0.1.0)
4
+ openai-client (0.3.0)
5
5
  faraday (~> 1.8)
6
6
  faraday_middleware (~> 1.2)
7
7
 
data/README.md CHANGED
@@ -26,16 +26,46 @@ Openai::Client.configure do |c|
26
26
  c.access_token = 'access_token'
27
27
  c.organization_id = 'organization_id' # optional
28
28
  end
29
+ ```
29
30
 
31
+ ## OpenAI Models API
32
+ ```ruby
30
33
  # Models
31
34
  Openai::Client.models.list
32
35
 
33
36
  # Find a Model
34
37
  Openai::Client.models.find(model_id)
35
38
  ```
39
+ ## OpenAI Completions API
40
+ ```ruby
41
+ request_body = {
42
+ model: 'text-davinci-003',
43
+ prompt: 'Say this is a test',
44
+ max_tokens: 7,
45
+ temperature: 0,
46
+ top_p: 1,
47
+ n: 1,
48
+ stream: false,
49
+ logprobs: nil,
50
+ stop: "\n"
51
+ }
52
+ Openai::Client.completions.create(request_body)
53
+ ```
54
+ [Completions request body documentation](https://platform.openai.com/docs/api-reference/completions/create)
55
+
56
+ ## OpenAI Edits API
57
+ ```ruby
58
+ request_body = {
59
+ model: 'text-davinci-edit-001',
60
+ input: 'What day of the wek is it?',
61
+ instruction: 'Fix the spelling mistakes'
62
+ }
63
+ Openai::Client.edits.create(request_body)
64
+ ```
65
+ [Edits request body documentation](https://platform.openai.com/docs/api-reference/edits/create)
36
66
 
37
67
  ## Contributing
38
68
  Bug reports and pull requests are welcome on GitHub at https://github.com/itikhonenko/openai-client.
39
69
 
40
70
  ## License
41
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
71
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openai
4
+ module Client
5
+ class Completions
6
+ PATH = 'completions'
7
+
8
+ # @api public
9
+ # Public: Makes an API call to create a completion.
10
+ #
11
+ # @param [Hash] body request body
12
+ #
13
+ # @return [Hash] a hash with a completion
14
+ def create(body)
15
+ Http.new.post(PATH, body).body
16
+ rescue StandardError
17
+ nil
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openai
4
+ module Client
5
+ class Edits
6
+ PATH = 'edits'
7
+
8
+ # @api public
9
+ # Public: Makes an API call to create edit.
10
+ #
11
+ # @param [Hash] body request body
12
+ #
13
+ # @return [Hash] a hash with edit
14
+ def create(body)
15
+ Http.new.post(PATH, body).body
16
+ rescue StandardError
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.2.1'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
data/lib/openai/client.rb CHANGED
@@ -9,12 +9,14 @@ require 'openai/client/configuration'
9
9
  require 'openai/client/configurable'
10
10
  require 'openai/client/http'
11
11
  require 'openai/client/models'
12
+ require 'openai/client/edits'
13
+ require 'openai/client/completions'
12
14
 
13
15
  module Openai
14
16
  module Client
15
17
  extend Configurable
16
18
 
17
- ATTRS = ['models'].freeze
19
+ ATTRS = ['models', 'edits', 'completions'].freeze
18
20
 
19
21
  class << self
20
22
  ATTRS.each do |attr|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ihor Tykhonenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-06 00:00:00.000000000 Z
11
+ date: 2023-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -54,12 +54,13 @@ files:
54
54
  - README.md
55
55
  - Rakefile
56
56
  - lib/openai/client.rb
57
+ - lib/openai/client/completions.rb
57
58
  - lib/openai/client/configurable.rb
58
59
  - lib/openai/client/configuration.rb
60
+ - lib/openai/client/edits.rb
59
61
  - lib/openai/client/http.rb
60
62
  - lib/openai/client/models.rb
61
63
  - lib/openai/client/version.rb
62
- - openai-client-0.1.0.gem
63
64
  - sig/openai/client.rbs
64
65
  homepage: https://github.com/itikhonenko/openai-client
65
66
  licenses:
Binary file