ruby-openai 3.0.0 → 3.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +1 -1
- data/README.md +1 -53
- data/lib/ruby/openai/client.rb +2 -55
- data/lib/ruby/openai/version.rb +1 -1
- data/lib/ruby/openai.rb +0 -1
- metadata +1 -2
- 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: 2a823ba01c0dbec587f96e5d2d59b6eb67e48c348b00a7e78f415c6b65583d05
|
4
|
+
data.tar.gz: 98e7ae98831997f66bcbd73c644c78b0f5ed291b5b98c6ca01e5152596ca7b25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15a75647453b2b526680b5e2d3b7bc3d5ef6b05f223bdef0194e751f829228d9db7d17d5c483db66bf7706983c4d996ff4c348b505e6d52b6cbb5ef523e68133
|
7
|
+
data.tar.gz: a7362b11bfeefa471e70369696d746d5c89c201ef374799a6163dbad814f405d7642861d588ef6360f088e21d41ba4b10e7f40467d2a4d515767ea66bf52b4d3
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,13 @@ 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.1] - 2022-12-26
|
9
|
+
|
10
|
+
### Removed
|
11
|
+
|
12
|
+
- [BREAKING] Remove deprecated answers, classifications, embeddings, engines and search endpoints.
|
13
|
+
- [BREAKING] Remove ability to pass engine to completions and embeddings outside of the parameters hash.
|
14
|
+
|
8
15
|
## [3.0.0] - 2022-12-26
|
9
16
|
|
10
17
|
### Added
|
@@ -15,8 +22,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
15
22
|
### Removed
|
16
23
|
|
17
24
|
- [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
25
|
- [BREAKING] Remove ability to pass API version directly to endpoints.
|
21
26
|
|
22
27
|
## [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/version.rb
CHANGED
data/lib/ruby/openai.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex
|
@@ -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
|