Skip to content

Commit 8b33a23

Browse files
committed
Add spec & docs for Model#delete
1 parent 239a820 commit 8b33a23

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ client.models.list
328328
client.models.retrieve(id: "gpt-4o")
329329
```
330330

331+
You can also delete any finetuned model you generated, if you're an account Owner on your OpenAI organization:
332+
333+
```ruby
334+
client.models.delete(id: "ft:gpt-4o-mini:acemeco:suffix:abc123")
335+
```
336+
331337
### Chat
332338

333339
GPT is a model that can be used to generate text in a conversational style. You can use it to [generate a response](https://platform.openai.com/docs/api-reference/chat/create) to a sequence of [messages](https://platform.openai.com/docs/guides/chat/introduction):
@@ -858,6 +864,12 @@ You can also capture the events for a job:
858864
client.finetunes.list_events(id: fine_tune_id)
859865
```
860866

867+
You can also delete any finetuned model you generated, if you're an account Owner on your OpenAI organization:
868+
869+
```ruby
870+
client.models.delete(id: fine_tune_id)
871+
```
872+
861873
### Vector Stores
862874

863875
Vector Store objects give the File Search tool the ability to search your files.

spec/fixtures/cassettes/models_delete.yml

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/openai/client/models_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,21 @@
2222
end
2323
end
2424
end
25+
26+
describe "#delete" do
27+
let(:cassette) { "models delete" }
28+
let(:model_id) { "ft:123" }
29+
30+
it "sends request to the correct endpoint" do
31+
VCR.use_cassette(cassette) do
32+
OpenAI::Client.new.models.delete(id: model_id)
33+
rescue Faraday::ResourceNotFound => e
34+
error_expected = "The model '#{model_id}' does not exist"
35+
expect(e.response.dig(:body, "error", "message")).to eq(error_expected)
36+
37+
# Just verify the exception is raised as expected
38+
expect(e).to be_a(Faraday::ResourceNotFound)
39+
end
40+
end
41+
end
2542
end

0 commit comments

Comments
 (0)