Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2054d71

Browse files
authoredJan 12, 2024
refactor(api): remove deprecated endpoints (#621)
The fine tunes and edits APIs are no longer provided by OpenAI. This is not a breaking change as attempting to call these APIs, even on older versions, will result in an error at runtime.
1 parent 2a1731a commit 2054d71

File tree

12 files changed

+13
-763
lines changed

12 files changed

+13
-763
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 57
1+
configured_endpoints: 51

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ a subclass of `APIError` will be thrown:
272272
<!-- prettier-ignore -->
273273
```ts
274274
async function main() {
275-
const fineTune = await openai.fineTunes
276-
.create({ training_file: 'file-XGinujblHPwGLSztz8cPS8XY' })
275+
const job = await openai.fineTuning.jobs
276+
.create({ model: 'gpt-3.5-turbo', training_file: 'file-abc123' })
277277
.catch((err) => {
278278
if (err instanceof OpenAI.APIError) {
279279
console.log(err.status); // 400

‎api.md

-26
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ Methods:
4848

4949
- <code title="post /chat/completions">client.chat.completions.<a href="./src/resources/chat/completions.ts">create</a>({ ...params }) -> ChatCompletion</code>
5050

51-
# Edits
52-
53-
Types:
54-
55-
- <code><a href="./src/resources/edits.ts">Edit</a></code>
56-
57-
Methods:
58-
59-
- <code title="post /edits">client.edits.<a href="./src/resources/edits.ts">create</a>({ ...params }) -> Edit</code>
60-
6151
# Embeddings
6252

6353
Types:
@@ -169,22 +159,6 @@ Methods:
169159
- <code title="post /fine_tuning/jobs/{fine_tuning_job_id}/cancel">client.fineTuning.jobs.<a href="./src/resources/fine-tuning/jobs.ts">cancel</a>(fineTuningJobId) -> FineTuningJob</code>
170160
- <code title="get /fine_tuning/jobs/{fine_tuning_job_id}/events">client.fineTuning.jobs.<a href="./src/resources/fine-tuning/jobs.ts">listEvents</a>(fineTuningJobId, { ...params }) -> FineTuningJobEventsPage</code>
171161

172-
# FineTunes
173-
174-
Types:
175-
176-
- <code><a href="./src/resources/fine-tunes.ts">FineTune</a></code>
177-
- <code><a href="./src/resources/fine-tunes.ts">FineTuneEvent</a></code>
178-
- <code><a href="./src/resources/fine-tunes.ts">FineTuneEventsListResponse</a></code>
179-
180-
Methods:
181-
182-
- <code title="post /fine-tunes">client.fineTunes.<a href="./src/resources/fine-tunes.ts">create</a>({ ...params }) -> FineTune</code>
183-
- <code title="get /fine-tunes/{fine_tune_id}">client.fineTunes.<a href="./src/resources/fine-tunes.ts">retrieve</a>(fineTuneId) -> FineTune</code>
184-
- <code title="get /fine-tunes">client.fineTunes.<a href="./src/resources/fine-tunes.ts">list</a>() -> FineTunesPage</code>
185-
- <code title="post /fine-tunes/{fine_tune_id}/cancel">client.fineTunes.<a href="./src/resources/fine-tunes.ts">cancel</a>(fineTuneId) -> FineTune</code>
186-
- <code title="get /fine-tunes/{fine_tune_id}/events">client.fineTunes.<a href="./src/resources/fine-tunes.ts">listEvents</a>(fineTuneId, { ...params }) -> FineTuneEventsListResponse</code>
187-
188162
# Beta
189163

190164
## Chat

‎src/index.ts

-16
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,13 @@ export class OpenAI extends Core.APIClient {
142142

143143
completions: API.Completions = new API.Completions(this);
144144
chat: API.Chat = new API.Chat(this);
145-
edits: API.Edits = new API.Edits(this);
146145
embeddings: API.Embeddings = new API.Embeddings(this);
147146
files: API.Files = new API.Files(this);
148147
images: API.Images = new API.Images(this);
149148
audio: API.Audio = new API.Audio(this);
150149
moderations: API.Moderations = new API.Moderations(this);
151150
models: API.Models = new API.Models(this);
152151
fineTuning: API.FineTuning = new API.FineTuning(this);
153-
fineTunes: API.FineTunes = new API.FineTunes(this);
154152
beta: API.Beta = new API.Beta(this);
155153

156154
protected override defaultQuery(): Core.DefaultQuery | undefined {
@@ -251,10 +249,6 @@ export namespace OpenAI {
251249
export import ChatCompletionCreateParamsNonStreaming = API.ChatCompletionCreateParamsNonStreaming;
252250
export import ChatCompletionCreateParamsStreaming = API.ChatCompletionCreateParamsStreaming;
253251

254-
export import Edits = API.Edits;
255-
export import Edit = API.Edit;
256-
export import EditCreateParams = API.EditCreateParams;
257-
258252
export import Embeddings = API.Embeddings;
259253
export import CreateEmbeddingResponse = API.CreateEmbeddingResponse;
260254
export import Embedding = API.Embedding;
@@ -289,16 +283,6 @@ export namespace OpenAI {
289283

290284
export import FineTuning = API.FineTuning;
291285

292-
export import FineTunes = API.FineTunes;
293-
export import FineTune = API.FineTune;
294-
export import FineTuneEvent = API.FineTuneEvent;
295-
export import FineTuneEventsListResponse = API.FineTuneEventsListResponse;
296-
export import FineTunesPage = API.FineTunesPage;
297-
export import FineTuneCreateParams = API.FineTuneCreateParams;
298-
export import FineTuneListEventsParams = API.FineTuneListEventsParams;
299-
export import FineTuneListEventsParamsNonStreaming = API.FineTuneListEventsParamsNonStreaming;
300-
export import FineTuneListEventsParamsStreaming = API.FineTuneListEventsParamsStreaming;
301-
302286
export import Beta = API.Beta;
303287

304288
export import FunctionDefinition = API.FunctionDefinition;

‎src/resources/chat/completions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export interface ChatCompletionTool {
594594
* will not call a function and instead generates a message. `auto` means the model
595595
* can pick between generating a message or calling a function. Specifying a
596596
* particular function via
597-
* `{"type: "function", "function": {"name": "my_function"}}` forces the model to
597+
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
598598
* call that function.
599599
*
600600
* `none` is the default when no functions are present. `auto` is the default if
@@ -807,7 +807,7 @@ export interface ChatCompletionCreateParamsBase {
807807
* will not call a function and instead generates a message. `auto` means the model
808808
* can pick between generating a message or calling a function. Specifying a
809809
* particular function via
810-
* `{"type: "function", "function": {"name": "my_function"}}` forces the model to
810+
* `{"type": "function", "function": {"name": "my_function"}}` forces the model to
811811
* call that function.
812812
*
813813
* `none` is the default when no functions are present. `auto` is the default if

‎src/resources/completions.ts

+6-18
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,7 @@ export interface CompletionCreateParamsBase {
131131
* [Model overview](https://platform.openai.com/docs/models/overview) for
132132
* descriptions of them.
133133
*/
134-
model:
135-
| (string & {})
136-
| 'babbage-002'
137-
| 'davinci-002'
138-
| 'gpt-3.5-turbo-instruct'
139-
| 'text-davinci-003'
140-
| 'text-davinci-002'
141-
| 'text-davinci-001'
142-
| 'code-davinci-002'
143-
| 'text-curie-001'
144-
| 'text-babbage-001'
145-
| 'text-ada-001';
134+
model: (string & {}) | 'gpt-3.5-turbo-instruct' | 'davinci-002' | 'babbage-002';
146135

147136
/**
148137
* The prompt(s) to generate completions for, encoded as a string, array of
@@ -186,12 +175,11 @@ export interface CompletionCreateParamsBase {
186175
*
187176
* Accepts a JSON object that maps tokens (specified by their token ID in the GPT
188177
* tokenizer) to an associated bias value from -100 to 100. You can use this
189-
* [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to
190-
* convert text to token IDs. Mathematically, the bias is added to the logits
191-
* generated by the model prior to sampling. The exact effect will vary per model,
192-
* but values between -1 and 1 should decrease or increase likelihood of selection;
193-
* values like -100 or 100 should result in a ban or exclusive selection of the
194-
* relevant token.
178+
* [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs.
179+
* Mathematically, the bias is added to the logits generated by the model prior to
180+
* sampling. The exact effect will vary per model, but values between -1 and 1
181+
* should decrease or increase likelihood of selection; values like -100 or 100
182+
* should result in a ban or exclusive selection of the relevant token.
195183
*
196184
* As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token
197185
* from being generated.

‎src/resources/edits.ts

-109
This file was deleted.

‎src/resources/fine-tunes.ts

-423
This file was deleted.

‎src/resources/fine-tuning/jobs.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { CursorPage, type CursorPageParams } from 'openai/pagination';
88

99
export class Jobs extends APIResource {
1010
/**
11-
* Creates a job that fine-tunes a specified model from a given dataset.
11+
* Creates a fine-tuning job which begins the process of creating a new model from
12+
* a given dataset.
1213
*
1314
* Response includes details of the enqueued job including job status and the name
1415
* of the fine-tuned models once complete.

‎src/resources/index.ts

-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export {
1414
Completions,
1515
} from './completions';
1616
export { CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, Embeddings } from './embeddings';
17-
export { Edit, EditCreateParams, Edits } from './edits';
1817
export {
1918
FileContent,
2019
FileDeleted,
@@ -24,17 +23,6 @@ export {
2423
FileObjectsPage,
2524
Files,
2625
} from './files';
27-
export {
28-
FineTune,
29-
FineTuneEvent,
30-
FineTuneEventsListResponse,
31-
FineTuneCreateParams,
32-
FineTuneListEventsParams,
33-
FineTuneListEventsParamsNonStreaming,
34-
FineTuneListEventsParamsStreaming,
35-
FineTunesPage,
36-
FineTunes,
37-
} from './fine-tunes';
3826
export { FineTuning } from './fine-tuning/fine-tuning';
3927
export {
4028
Image,

‎tests/api-resources/edits.test.ts

-36
This file was deleted.

‎tests/api-resources/fine-tunes.test.ts

-117
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.