ruby-openai 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +14 -16
- data/README.md +15 -4
- data/lib/ruby/openai/client.rb +14 -6
- data/lib/ruby/openai/files.rb +1 -1
- data/lib/ruby/openai/finetunes.rb +2 -2
- data/lib/ruby/openai/images.rb +3 -3
- data/lib/ruby/openai/version.rb +1 -1
- data/ruby-openai.gemspec +1 -1
- metadata +4 -5
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bd89bdf882febca95eb2a6ca2d0d28afda7fa0d73a369ee61cb56038376247c
|
4
|
+
data.tar.gz: 5e9ee20773b1322dc940655ed3cbd040a667f27337f0a310bb6bbd9db8df2931
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40388adbfd46c7461f56d088dbc346206b1e44d27f32cfef766544dce0d76843723d10c4d050ed2564d8f940fc1daa0631084c412d10f75c7ee185f5cffbec43
|
7
|
+
data.tar.gz: a94573f8cfd2cd0a488746a1971e72a678d0761732c586c7d2d9ee4c74f7496d2a214d9c09b90371dc9cd86da6ddf64d58d91ff3bbb9c7eba70bb8f462e78e5c
|
data/.circleci/config.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [3.0.3] - 2023-01-07
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Add ability to run the specs without VCR cassettes using `NO_VCR=true bundle exec rspec`.
|
13
|
+
- Add Ruby 3.2 to CircleCI config - thanks [@petergoldstein](https://github.com/petergoldstein)!
|
14
|
+
- A bit of detail added to the README on DALLE image sizes - thanks [@ndemianc](https://github.com/ndemianc)!
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Fix finetunes and files uploads endpoints - thanks [@chaadow](https://github.com/chaadow) for your PR on this and [@petergoldstein](https://github.com/petergoldstein) for the PR we ultimately went with.
|
19
|
+
|
8
20
|
## [3.0.2] - 2022-12-27
|
9
21
|
|
10
22
|
### Fixed
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-openai (3.0.
|
5
|
-
httparty (>= 0.18.1, < 0.
|
4
|
+
ruby-openai (3.0.3)
|
5
|
+
httparty (>= 0.18.1, < 0.22.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.8.
|
11
|
-
public_suffix (>= 2.0.2, <
|
10
|
+
addressable (2.8.1)
|
11
|
+
public_suffix (>= 2.0.2, < 6.0)
|
12
12
|
ast (2.4.2)
|
13
13
|
byebug (11.1.3)
|
14
14
|
crack (0.4.5)
|
@@ -16,18 +16,16 @@ GEM
|
|
16
16
|
diff-lcs (1.5.0)
|
17
17
|
dotenv (2.8.1)
|
18
18
|
hashdiff (1.0.1)
|
19
|
-
httparty (0.
|
20
|
-
|
19
|
+
httparty (0.21.0)
|
20
|
+
mini_mime (>= 1.0.0)
|
21
21
|
multi_xml (>= 0.5.2)
|
22
22
|
json (2.6.3)
|
23
|
-
|
24
|
-
mime-types-data (~> 3.2015)
|
25
|
-
mime-types-data (3.2022.0105)
|
23
|
+
mini_mime (1.1.2)
|
26
24
|
multi_xml (0.6.0)
|
27
25
|
parallel (1.22.1)
|
28
26
|
parser (3.1.3.0)
|
29
27
|
ast (~> 2.4.1)
|
30
|
-
public_suffix (
|
28
|
+
public_suffix (5.0.1)
|
31
29
|
rainbow (3.1.1)
|
32
30
|
rake (13.0.6)
|
33
31
|
regexp_parser (2.6.1)
|
@@ -38,24 +36,24 @@ GEM
|
|
38
36
|
rspec-mocks (~> 3.12.0)
|
39
37
|
rspec-core (3.12.0)
|
40
38
|
rspec-support (~> 3.12.0)
|
41
|
-
rspec-expectations (3.12.
|
39
|
+
rspec-expectations (3.12.1)
|
42
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
41
|
rspec-support (~> 3.12.0)
|
44
|
-
rspec-mocks (3.12.
|
42
|
+
rspec-mocks (3.12.1)
|
45
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
46
44
|
rspec-support (~> 3.12.0)
|
47
45
|
rspec-support (3.12.0)
|
48
|
-
rubocop (1.
|
46
|
+
rubocop (1.42.0)
|
49
47
|
json (~> 2.3)
|
50
48
|
parallel (~> 1.10)
|
51
49
|
parser (>= 3.1.2.1)
|
52
50
|
rainbow (>= 2.2.2, < 4.0)
|
53
51
|
regexp_parser (>= 1.8, < 3.0)
|
54
52
|
rexml (>= 3.2.5, < 4.0)
|
55
|
-
rubocop-ast (>= 1.
|
53
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
56
54
|
ruby-progressbar (~> 1.7)
|
57
55
|
unicode-display_width (>= 1.4.0, < 3.0)
|
58
|
-
rubocop-ast (1.24.
|
56
|
+
rubocop-ast (1.24.1)
|
59
57
|
parser (>= 3.1.1.0)
|
60
58
|
ruby-progressbar (1.11.0)
|
61
59
|
unicode-display_width (2.3.0)
|
@@ -73,7 +71,7 @@ DEPENDENCIES
|
|
73
71
|
dotenv (~> 2.8.1)
|
74
72
|
rake (~> 13.0)
|
75
73
|
rspec (~> 3.12)
|
76
|
-
rubocop (~> 1.
|
74
|
+
rubocop (~> 1.42.0)
|
77
75
|
ruby-openai!
|
78
76
|
vcr (~> 6.1.0)
|
79
77
|
webmock (~> 3.18.1)
|
data/README.md
CHANGED
@@ -202,10 +202,11 @@ This fine-tuned model name can then be used in completions:
|
|
202
202
|
|
203
203
|
### Image Generation
|
204
204
|
|
205
|
-
Generate an image using DALL·E!
|
205
|
+
Generate an image using DALL·E! The size of any generated images must be one of `256x256`, `512x512` or `1024x1024` -
|
206
|
+
if not specified the image will default to `1024x1024`.
|
206
207
|
|
207
208
|
```ruby
|
208
|
-
response = client.images.generate(parameters: { prompt: "A baby sea otter cooking pasta wearing a hat of some sort" })
|
209
|
+
response = client.images.generate(parameters: { prompt: "A baby sea otter cooking pasta wearing a hat of some sort", size: "256x256" })
|
209
210
|
puts response.dig("data", 0, "url")
|
210
211
|
=> "https://oaidalleapiprodscus.blob.core.windows.net/private/org-Rf437IxKhh..."
|
211
212
|
```
|
@@ -249,9 +250,19 @@ Pass a string to check if it violates OpenAI's Content Policy:
|
|
249
250
|
|
250
251
|
## Development
|
251
252
|
|
252
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
253
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can run `bin/console` for an interactive prompt that will allow you to experiment.
|
253
254
|
|
254
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
255
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
256
|
+
|
257
|
+
## Release
|
258
|
+
|
259
|
+
First run the specs without VCR so they actually hit the API. This will cost about 2 cents. You'll need to add your `OPENAI_ACCESS_TOKEN=` in `.env`.
|
260
|
+
|
261
|
+
```
|
262
|
+
NO_VCR=true bundle exec rspec
|
263
|
+
```
|
264
|
+
|
265
|
+
Then update the version number in `version.rb`, update `CHANGELOG.md`, run `bundle install` to update Gemfile.lock, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
255
266
|
|
256
267
|
## Contributing
|
257
268
|
|
data/lib/ruby/openai/client.rb
CHANGED
@@ -8,15 +8,15 @@ module OpenAI
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def completions(parameters: {})
|
11
|
-
OpenAI::Client.
|
11
|
+
OpenAI::Client.json_post(path: "/completions", parameters: parameters)
|
12
12
|
end
|
13
13
|
|
14
14
|
def edits(parameters: {})
|
15
|
-
OpenAI::Client.
|
15
|
+
OpenAI::Client.json_post(path: "/edits", parameters: parameters)
|
16
16
|
end
|
17
17
|
|
18
18
|
def embeddings(parameters: {})
|
19
|
-
OpenAI::Client.
|
19
|
+
OpenAI::Client.json_post(path: "/embeddings", parameters: parameters)
|
20
20
|
end
|
21
21
|
|
22
22
|
def files
|
@@ -36,7 +36,7 @@ module OpenAI
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def moderations(parameters: {})
|
39
|
-
OpenAI::Client.
|
39
|
+
OpenAI::Client.json_post(path: "/moderations", parameters: parameters)
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.get(path:)
|
@@ -46,11 +46,19 @@ module OpenAI
|
|
46
46
|
)
|
47
47
|
end
|
48
48
|
|
49
|
-
def self.
|
49
|
+
def self.json_post(path:, parameters:)
|
50
50
|
HTTParty.post(
|
51
51
|
uri(path: path),
|
52
52
|
headers: headers,
|
53
|
-
body: parameters
|
53
|
+
body: parameters&.to_json
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.multipart_post(path:, parameters: nil)
|
58
|
+
HTTParty.post(
|
59
|
+
uri(path: path),
|
60
|
+
headers: headers.merge({ "Content-Type" => "multipart/form-data" }),
|
61
|
+
body: parameters
|
54
62
|
)
|
55
63
|
end
|
56
64
|
|
data/lib/ruby/openai/files.rb
CHANGED
@@ -10,7 +10,7 @@ module OpenAI
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create(parameters: {})
|
13
|
-
OpenAI::Client.
|
13
|
+
OpenAI::Client.json_post(path: "/fine-tunes", parameters: parameters)
|
14
14
|
end
|
15
15
|
|
16
16
|
def retrieve(id:)
|
@@ -18,7 +18,7 @@ module OpenAI
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def cancel(id:)
|
21
|
-
OpenAI::Client.
|
21
|
+
OpenAI::Client.multipart_post(path: "/fine-tunes/#{id}/cancel")
|
22
22
|
end
|
23
23
|
|
24
24
|
def events(id:)
|
data/lib/ruby/openai/images.rb
CHANGED
@@ -6,15 +6,15 @@ module OpenAI
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def generate(parameters: {})
|
9
|
-
OpenAI::Client.
|
9
|
+
OpenAI::Client.json_post(path: "/images/generations", parameters: parameters)
|
10
10
|
end
|
11
11
|
|
12
12
|
def edit(parameters: {})
|
13
|
-
OpenAI::Client.
|
13
|
+
OpenAI::Client.multipart_post(path: "/images/edits", parameters: open_files(parameters))
|
14
14
|
end
|
15
15
|
|
16
16
|
def variations(parameters: {})
|
17
|
-
OpenAI::Client.
|
17
|
+
OpenAI::Client.multipart_post(path: "/images/variations", parameters: open_files(parameters))
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
data/lib/ruby/openai/version.rb
CHANGED
data/ruby-openai.gemspec
CHANGED
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_dependency "httparty", ">= 0.18.1", "< 0.
|
28
|
+
spec.add_dependency "httparty", ">= 0.18.1", "< 0.22.0"
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-openai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 0.18.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.22.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 0.18.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.22.0
|
33
33
|
description:
|
34
34
|
email:
|
35
35
|
- alexrudall@users.noreply.github.com
|
@@ -44,7 +44,6 @@ files:
|
|
44
44
|
- ".gitignore"
|
45
45
|
- ".rspec"
|
46
46
|
- ".rubocop.yml"
|
47
|
-
- ".travis.yml"
|
48
47
|
- CHANGELOG.md
|
49
48
|
- CODE_OF_CONDUCT.md
|
50
49
|
- CONTRIBUTING.md
|