Skip to content

Commit d28d1f1

Browse files
authored
Merge pull request #137 from alexrudall/remove-deprecated-endpoints
Remove deprecated endpoints
2 parents d71fe0f + 0e0f0c4 commit d28d1f1

21 files changed

+3
-1660
lines changed

README.md

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ You may need to wait a short time for processing to complete. Once processed, yo
188188
fine_tuned_model = JSON.parse(response.body)["fine_tuned_model"]
189189
```
190190

191-
This fine-tuned model name can then be used in classifications:
191+
This fine-tuned model name can then be used in completions:
192192

193193
```ruby
194194
response = client.completions(
@@ -247,58 +247,6 @@ Pass a string to check if it violates OpenAI's Content Policy:
247247
=> 5.505014632944949e-05
248248
```
249249

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-
302250
## Development
303251

304252
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.

lib/ruby/openai.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require "httparty"
22
require "ruby/openai/client"
3-
require "ruby/openai/engines"
43
require "ruby/openai/files"
54
require "ruby/openai/finetunes"
65
require "ruby/openai/images"

lib/ruby/openai/client.rb

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,18 @@ def initialize(access_token: nil, organization_id: nil)
77
Ruby::OpenAI.configuration.organization_id = organization_id if organization_id
88
end
99

10-
def answers(parameters: {})
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: {})
2911
OpenAI::Client.post(path: "/completions", parameters: parameters)
3012
end
3113

3214
def edits(parameters: {})
3315
OpenAI::Client.post(path: "/edits", parameters: parameters)
3416
end
3517

36-
def embeddings(engine: nil, parameters: {})
37-
parameters = deprecate_engine(engine: engine, method: "embeddings", parameters: parameters)
38-
18+
def embeddings(parameters: {})
3919
OpenAI::Client.post(path: "/embeddings", parameters: parameters)
4020
end
4121

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-
4922
def files
5023
@files ||= OpenAI::Files.new
5124
end
@@ -66,14 +39,6 @@ def moderations(parameters: {})
6639
OpenAI::Client.post(path: "/moderations", parameters: parameters)
6740
end
6841

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-
7742
def self.get(path:)
7843
HTTParty.get(
7944
uri(path: path),
@@ -107,23 +72,5 @@ def self.delete(path:)
10772
"OpenAI-Organization" => Ruby::OpenAI.configuration.organization_id
10873
}
10974
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
12875
end
12976
end

lib/ruby/openai/engines.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)