ruby-openai 3.0.0 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -2
- data/Gemfile.lock +1 -1
- data/README.md +1 -53
- data/lib/ruby/openai/client.rb +2 -55
- data/lib/ruby/openai/finetunes.rb +1 -1
- data/lib/ruby/openai/images.rb +1 -1
- data/lib/ruby/openai/version.rb +1 -1
- data/lib/ruby/openai.rb +0 -1
- metadata +2 -3
- data/lib/ruby/openai/engines.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73d5bf4fb81e5c4901998a20fcebc52a0f2c81edc12e7e8abac06a2171dd5c6e
|
4
|
+
data.tar.gz: 4775fd5959d4c5949cec0a02212a73ddc2b3af8cde3f1f9d996bcd3c71031c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a8d81ddbb8e2542f968549ef4014600c7cd6fff78404501a7d72d322d823651842e0b0f1aaf96238d5a2ea870eda7e626c53652e21aba105703b062c746487c
|
7
|
+
data.tar.gz: 3ff7ba70a3fc55b2e9e56144a221ac485e3d3c2854980a3b340aeffc4c0a544bed8a2506d7c71f387403482eb4c8565f4a6705dad582f47ea726593d4c82a135
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,20 @@ 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.2] - 2022-12-27
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Fixed Images#generate and Finetunes#create which were broken by a double call of to_json.
|
13
|
+
- Thanks [@konung](https://github.com/konung) for spotting this!
|
14
|
+
|
15
|
+
## [3.0.1] - 2022-12-26
|
16
|
+
|
17
|
+
### Removed
|
18
|
+
|
19
|
+
- [BREAKING] Remove deprecated answers, classifications, embeddings, engines and search endpoints.
|
20
|
+
- [BREAKING] Remove ability to pass engine to completions and embeddings outside of the parameters hash.
|
21
|
+
|
8
22
|
## [3.0.0] - 2022-12-26
|
9
23
|
|
10
24
|
### Added
|
@@ -15,8 +29,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
15
29
|
### Removed
|
16
30
|
|
17
31
|
- [BREAKING] Remove ability to include access_token directly via ENV vars.
|
18
|
-
- [BREAKING] Remove deprecated answers, classifications, embeddings, engines and search endpoints.
|
19
|
-
- [BREAKING] Remove ability to pass engine to completions and embeddings outside of the parameters hash.
|
20
32
|
- [BREAKING] Remove ability to pass API version directly to endpoints.
|
21
33
|
|
22
34
|
## [2.3.0] - 2022-12-23
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -188,7 +188,7 @@ You may need to wait a short time for processing to complete. Once processed, yo
|
|
188
188
|
fine_tuned_model = JSON.parse(response.body)["fine_tuned_model"]
|
189
189
|
```
|
190
190
|
|
191
|
-
This fine-tuned model name can then be used in
|
191
|
+
This fine-tuned model name can then be used in completions:
|
192
192
|
|
193
193
|
```ruby
|
194
194
|
response = client.completions(
|
@@ -247,58 +247,6 @@ Pass a string to check if it violates OpenAI's Content Policy:
|
|
247
247
|
=> 5.505014632944949e-05
|
248
248
|
```
|
249
249
|
|
250
|
-
### Classifications
|
251
|
-
|
252
|
-
Pass examples and a query to predict the most likely labels:
|
253
|
-
|
254
|
-
```ruby
|
255
|
-
response = client.classifications(parameters: {
|
256
|
-
examples: [
|
257
|
-
["A happy moment", "Positive"],
|
258
|
-
["I am sad.", "Negative"],
|
259
|
-
["I am feeling awesome", "Positive"]
|
260
|
-
],
|
261
|
-
query: "It is a raining day :(",
|
262
|
-
model: "text-ada-001"
|
263
|
-
})
|
264
|
-
```
|
265
|
-
|
266
|
-
Or use the ID of a file you've uploaded:
|
267
|
-
|
268
|
-
```ruby
|
269
|
-
response = client.classifications(parameters: {
|
270
|
-
file: "123abc,
|
271
|
-
query: "It is a raining day :(",
|
272
|
-
model: "text-ada-001"
|
273
|
-
})
|
274
|
-
```
|
275
|
-
|
276
|
-
### Answers
|
277
|
-
|
278
|
-
Pass documents, a question string, and an example question/response to get an answer to a question:
|
279
|
-
|
280
|
-
```ruby
|
281
|
-
response = client.answers(parameters: {
|
282
|
-
documents: ["Puppy A is happy.", "Puppy B is sad."],
|
283
|
-
question: "which puppy is happy?",
|
284
|
-
model: "text-curie-001",
|
285
|
-
examples_context: "In 2017, U.S. life expectancy was 78.6 years.",
|
286
|
-
examples: [["What is human life expectancy in the United States?","78 years."]],
|
287
|
-
})
|
288
|
-
```
|
289
|
-
|
290
|
-
Or use the ID of a file you've uploaded:
|
291
|
-
|
292
|
-
```ruby
|
293
|
-
response = client.answers(parameters: {
|
294
|
-
file: "123abc",
|
295
|
-
question: "which puppy is happy?",
|
296
|
-
model: "text-curie-001",
|
297
|
-
examples_context: "In 2017, U.S. life expectancy was 78.6 years.",
|
298
|
-
examples: [["What is human life expectancy in the United States?","78 years."]],
|
299
|
-
})
|
300
|
-
```
|
301
|
-
|
302
250
|
## Development
|
303
251
|
|
304
252
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/ruby/openai/client.rb
CHANGED
@@ -7,25 +7,7 @@ module OpenAI
|
|
7
7
|
Ruby::OpenAI.configuration.organization_id = organization_id if organization_id
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
warn "[DEPRECATION WARNING] [ruby-openai] `Client#answers` is deprecated and will
|
12
|
-
be removed from the OpenAI API on 3 December 2022 and from ruby-openai v3.0.
|
13
|
-
More information: https://help.openai.com/en/articles/6233728-answers-transition-guide"
|
14
|
-
|
15
|
-
OpenAI::Client.post(path: "/answers", parameters: parameters)
|
16
|
-
end
|
17
|
-
|
18
|
-
def classifications(parameters: {})
|
19
|
-
warn "[DEPRECATION WARNING] [ruby-openai] `Client#classifications` is deprecated and will
|
20
|
-
be removed from the OpenAI API on 3 December 2022 and from ruby-openai v3.0.
|
21
|
-
More information: https://help.openai.com/en/articles/6272941-classifications-transition-guide"
|
22
|
-
|
23
|
-
OpenAI::Client.post(path: "/classifications", parameters: parameters)
|
24
|
-
end
|
25
|
-
|
26
|
-
def completions(engine: nil, parameters: {})
|
27
|
-
parameters = deprecate_engine(engine: engine, method: "completions", parameters: parameters)
|
28
|
-
|
10
|
+
def completions(parameters: {})
|
29
11
|
OpenAI::Client.post(path: "/completions", parameters: parameters)
|
30
12
|
end
|
31
13
|
|
@@ -33,19 +15,10 @@ module OpenAI
|
|
33
15
|
OpenAI::Client.post(path: "/edits", parameters: parameters)
|
34
16
|
end
|
35
17
|
|
36
|
-
def embeddings(
|
37
|
-
parameters = deprecate_engine(engine: engine, method: "embeddings", parameters: parameters)
|
38
|
-
|
18
|
+
def embeddings(parameters: {})
|
39
19
|
OpenAI::Client.post(path: "/embeddings", parameters: parameters)
|
40
20
|
end
|
41
21
|
|
42
|
-
def engines
|
43
|
-
warn "[DEPRECATION WARNING] [ruby-openai] `Client#engines` is deprecated and will
|
44
|
-
be removed from ruby-openai v3.0. Use `Client#models` instead."
|
45
|
-
|
46
|
-
@engines ||= OpenAI::Engines.new
|
47
|
-
end
|
48
|
-
|
49
22
|
def files
|
50
23
|
@files ||= OpenAI::Files.new
|
51
24
|
end
|
@@ -66,14 +39,6 @@ module OpenAI
|
|
66
39
|
OpenAI::Client.post(path: "/moderations", parameters: parameters)
|
67
40
|
end
|
68
41
|
|
69
|
-
def search(engine:, parameters: {})
|
70
|
-
warn "[DEPRECATION WARNING] [ruby-openai] `Client#search` is deprecated and will
|
71
|
-
be removed from the OpenAI API on 3 December 2022 and from ruby-openai v3.0.
|
72
|
-
More information: https://help.openai.com/en/articles/6272952-search-transition-guide"
|
73
|
-
|
74
|
-
OpenAI::Client.post(path: "/engines/#{engine}/search", parameters: parameters)
|
75
|
-
end
|
76
|
-
|
77
42
|
def self.get(path:)
|
78
43
|
HTTParty.get(
|
79
44
|
uri(path: path),
|
@@ -107,23 +72,5 @@ module OpenAI
|
|
107
72
|
"OpenAI-Organization" => Ruby::OpenAI.configuration.organization_id
|
108
73
|
}
|
109
74
|
end
|
110
|
-
|
111
|
-
private
|
112
|
-
|
113
|
-
def deprecate_engine(engine:, method:, parameters:)
|
114
|
-
return parameters unless engine
|
115
|
-
|
116
|
-
parameters = { model: engine }.merge(parameters)
|
117
|
-
|
118
|
-
warn "[DEPRECATION WARNING] [ruby-openai] Passing `engine` directly to `Client##{method}` is
|
119
|
-
deprecated and will be removed in ruby-openai 3.0. Pass `model` within `parameters` instead:
|
120
|
-
client.completions(parameters: { #{parameters.map { |k, v| "#{k}: \"#{v}\"" }.join(', ')} })"
|
121
|
-
|
122
|
-
parameters
|
123
|
-
end
|
124
|
-
|
125
|
-
def documents_or_file(documents: nil, file: nil)
|
126
|
-
documents ? { documents: documents } : { file: file }
|
127
|
-
end
|
128
75
|
end
|
129
76
|
end
|
data/lib/ruby/openai/images.rb
CHANGED
data/lib/ruby/openai/version.rb
CHANGED
data/lib/ruby/openai.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -57,7 +57,6 @@ files:
|
|
57
57
|
- bin/setup
|
58
58
|
- lib/ruby/openai.rb
|
59
59
|
- lib/ruby/openai/client.rb
|
60
|
-
- lib/ruby/openai/engines.rb
|
61
60
|
- lib/ruby/openai/files.rb
|
62
61
|
- lib/ruby/openai/finetunes.rb
|
63
62
|
- lib/ruby/openai/images.rb
|
data/lib/ruby/openai/engines.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module OpenAI
|
2
|
-
class Engines
|
3
|
-
def initialize(access_token: nil, organization_id: nil)
|
4
|
-
Ruby::OpenAI.configuration.access_token = access_token if access_token
|
5
|
-
Ruby::OpenAI.configuration.organization_id = organization_id if organization_id
|
6
|
-
end
|
7
|
-
|
8
|
-
def list
|
9
|
-
OpenAI::Client.get(path: "/engines")
|
10
|
-
end
|
11
|
-
|
12
|
-
def retrieve(id:)
|
13
|
-
OpenAI::Client.get(path: "/engines/#{id}")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|