Skip to content

Commit 8dab142

Browse files
committed
refactor(api): remove deprecated endpoints (#1067)
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 d253af5 commit 8dab142

24 files changed

+59
-2032
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

+3-2
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ from openai import OpenAI
296296
client = OpenAI()
297297

298298
try:
299-
client.fine_tunes.create(
300-
training_file="file-XGinujblHPwGLSztz8cPS8XY",
299+
client.fine_tuning.jobs.create(
300+
model="gpt-3.5-turbo",
301+
training_file="file-abc123",
301302
)
302303
except openai.APIConnectionError as e:
303304
print("The server could not be reached")

api.md

-28
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,6 @@ Methods:
5050

5151
- <code title="post /chat/completions">client.chat.completions.<a href="./src/openai/resources/chat/completions.py">create</a>(\*\*<a href="src/openai/types/chat/completion_create_params.py">params</a>) -> <a href="./src/openai/types/chat/chat_completion.py">ChatCompletion</a></code>
5252

53-
# Edits
54-
55-
Types:
56-
57-
```python
58-
from openai.types import Edit
59-
```
60-
61-
Methods:
62-
63-
- <code title="post /edits">client.edits.<a href="./src/openai/resources/edits.py">create</a>(\*\*<a href="src/openai/types/edit_create_params.py">params</a>) -> <a href="./src/openai/types/edit.py">Edit</a></code>
64-
6553
# Embeddings
6654

6755
Types:
@@ -182,22 +170,6 @@ Methods:
182170
- <code title="post /fine_tuning/jobs/{fine_tuning_job_id}/cancel">client.fine_tuning.jobs.<a href="./src/openai/resources/fine_tuning/jobs.py">cancel</a>(fine_tuning_job_id) -> <a href="./src/openai/types/fine_tuning/fine_tuning_job.py">FineTuningJob</a></code>
183171
- <code title="get /fine_tuning/jobs/{fine_tuning_job_id}/events">client.fine_tuning.jobs.<a href="./src/openai/resources/fine_tuning/jobs.py">list_events</a>(fine_tuning_job_id, \*\*<a href="src/openai/types/fine_tuning/job_list_events_params.py">params</a>) -> <a href="./src/openai/types/fine_tuning/fine_tuning_job_event.py">SyncCursorPage[FineTuningJobEvent]</a></code>
184172

185-
# FineTunes
186-
187-
Types:
188-
189-
```python
190-
from openai.types import FineTune, FineTuneEvent, FineTuneEventsListResponse
191-
```
192-
193-
Methods:
194-
195-
- <code title="post /fine-tunes">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">create</a>(\*\*<a href="src/openai/types/fine_tune_create_params.py">params</a>) -> <a href="./src/openai/types/fine_tune.py">FineTune</a></code>
196-
- <code title="get /fine-tunes/{fine_tune_id}">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">retrieve</a>(fine_tune_id) -> <a href="./src/openai/types/fine_tune.py">FineTune</a></code>
197-
- <code title="get /fine-tunes">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">list</a>() -> <a href="./src/openai/types/fine_tune.py">SyncPage[FineTune]</a></code>
198-
- <code title="post /fine-tunes/{fine_tune_id}/cancel">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">cancel</a>(fine_tune_id) -> <a href="./src/openai/types/fine_tune.py">FineTune</a></code>
199-
- <code title="get /fine-tunes/{fine_tune_id}/events">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">list_events</a>(fine_tune_id, \*\*<a href="src/openai/types/fine_tune_list_events_params.py">params</a>) -> <a href="./src/openai/types/fine_tune_events_list_response.py">FineTuneEventsListResponse</a></code>
200-
201173
# Beta
202174

203175
## Assistants

src/openai/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,10 @@ def _reset_client() -> None: # type: ignore[reportUnusedFunction]
316316
beta as beta,
317317
chat as chat,
318318
audio as audio,
319-
edits as edits,
320319
files as files,
321320
images as images,
322321
models as models,
323322
embeddings as embeddings,
324-
fine_tunes as fine_tunes,
325323
completions as completions,
326324
fine_tuning as fine_tuning,
327325
moderations as moderations,

src/openai/_client.py

-12
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@
4949
class OpenAI(SyncAPIClient):
5050
completions: resources.Completions
5151
chat: resources.Chat
52-
edits: resources.Edits
5352
embeddings: resources.Embeddings
5453
files: resources.Files
5554
images: resources.Images
5655
audio: resources.Audio
5756
moderations: resources.Moderations
5857
models: resources.Models
5958
fine_tuning: resources.FineTuning
60-
fine_tunes: resources.FineTunes
6159
beta: resources.Beta
6260
with_raw_response: OpenAIWithRawResponse
6361

@@ -125,15 +123,13 @@ def __init__(
125123

126124
self.completions = resources.Completions(self)
127125
self.chat = resources.Chat(self)
128-
self.edits = resources.Edits(self)
129126
self.embeddings = resources.Embeddings(self)
130127
self.files = resources.Files(self)
131128
self.images = resources.Images(self)
132129
self.audio = resources.Audio(self)
133130
self.moderations = resources.Moderations(self)
134131
self.models = resources.Models(self)
135132
self.fine_tuning = resources.FineTuning(self)
136-
self.fine_tunes = resources.FineTunes(self)
137133
self.beta = resources.Beta(self)
138134
self.with_raw_response = OpenAIWithRawResponse(self)
139135

@@ -249,15 +245,13 @@ def _make_status_error(
249245
class AsyncOpenAI(AsyncAPIClient):
250246
completions: resources.AsyncCompletions
251247
chat: resources.AsyncChat
252-
edits: resources.AsyncEdits
253248
embeddings: resources.AsyncEmbeddings
254249
files: resources.AsyncFiles
255250
images: resources.AsyncImages
256251
audio: resources.AsyncAudio
257252
moderations: resources.AsyncModerations
258253
models: resources.AsyncModels
259254
fine_tuning: resources.AsyncFineTuning
260-
fine_tunes: resources.AsyncFineTunes
261255
beta: resources.AsyncBeta
262256
with_raw_response: AsyncOpenAIWithRawResponse
263257

@@ -325,15 +319,13 @@ def __init__(
325319

326320
self.completions = resources.AsyncCompletions(self)
327321
self.chat = resources.AsyncChat(self)
328-
self.edits = resources.AsyncEdits(self)
329322
self.embeddings = resources.AsyncEmbeddings(self)
330323
self.files = resources.AsyncFiles(self)
331324
self.images = resources.AsyncImages(self)
332325
self.audio = resources.AsyncAudio(self)
333326
self.moderations = resources.AsyncModerations(self)
334327
self.models = resources.AsyncModels(self)
335328
self.fine_tuning = resources.AsyncFineTuning(self)
336-
self.fine_tunes = resources.AsyncFineTunes(self)
337329
self.beta = resources.AsyncBeta(self)
338330
self.with_raw_response = AsyncOpenAIWithRawResponse(self)
339331

@@ -450,31 +442,27 @@ class OpenAIWithRawResponse:
450442
def __init__(self, client: OpenAI) -> None:
451443
self.completions = resources.CompletionsWithRawResponse(client.completions)
452444
self.chat = resources.ChatWithRawResponse(client.chat)
453-
self.edits = resources.EditsWithRawResponse(client.edits)
454445
self.embeddings = resources.EmbeddingsWithRawResponse(client.embeddings)
455446
self.files = resources.FilesWithRawResponse(client.files)
456447
self.images = resources.ImagesWithRawResponse(client.images)
457448
self.audio = resources.AudioWithRawResponse(client.audio)
458449
self.moderations = resources.ModerationsWithRawResponse(client.moderations)
459450
self.models = resources.ModelsWithRawResponse(client.models)
460451
self.fine_tuning = resources.FineTuningWithRawResponse(client.fine_tuning)
461-
self.fine_tunes = resources.FineTunesWithRawResponse(client.fine_tunes)
462452
self.beta = resources.BetaWithRawResponse(client.beta)
463453

464454

465455
class AsyncOpenAIWithRawResponse:
466456
def __init__(self, client: AsyncOpenAI) -> None:
467457
self.completions = resources.AsyncCompletionsWithRawResponse(client.completions)
468458
self.chat = resources.AsyncChatWithRawResponse(client.chat)
469-
self.edits = resources.AsyncEditsWithRawResponse(client.edits)
470459
self.embeddings = resources.AsyncEmbeddingsWithRawResponse(client.embeddings)
471460
self.files = resources.AsyncFilesWithRawResponse(client.files)
472461
self.images = resources.AsyncImagesWithRawResponse(client.images)
473462
self.audio = resources.AsyncAudioWithRawResponse(client.audio)
474463
self.moderations = resources.AsyncModerationsWithRawResponse(client.moderations)
475464
self.models = resources.AsyncModelsWithRawResponse(client.models)
476465
self.fine_tuning = resources.AsyncFineTuningWithRawResponse(client.fine_tuning)
477-
self.fine_tunes = resources.AsyncFineTunesWithRawResponse(client.fine_tunes)
478466
self.beta = resources.AsyncBetaWithRawResponse(client.beta)
479467

480468

src/openai/_module_client.py

-14
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ def __load__(self) -> resources.Beta:
1818
return _load_client().beta
1919

2020

21-
class EditsProxy(LazyProxy[resources.Edits]):
22-
@override
23-
def __load__(self) -> resources.Edits:
24-
return _load_client().edits
25-
26-
2721
class FilesProxy(LazyProxy[resources.Files]):
2822
@override
2923
def __load__(self) -> resources.Files:
@@ -54,12 +48,6 @@ def __load__(self) -> resources.Embeddings:
5448
return _load_client().embeddings
5549

5650

57-
class FineTunesProxy(LazyProxy[resources.FineTunes]):
58-
@override
59-
def __load__(self) -> resources.FineTunes:
60-
return _load_client().fine_tunes
61-
62-
6351
class CompletionsProxy(LazyProxy[resources.Completions]):
6452
@override
6553
def __load__(self) -> resources.Completions:
@@ -80,13 +68,11 @@ def __load__(self) -> resources.FineTuning:
8068

8169
chat: resources.Chat = ChatProxy().__as_proxied__()
8270
beta: resources.Beta = BetaProxy().__as_proxied__()
83-
edits: resources.Edits = EditsProxy().__as_proxied__()
8471
files: resources.Files = FilesProxy().__as_proxied__()
8572
audio: resources.Audio = AudioProxy().__as_proxied__()
8673
images: resources.Images = ImagesProxy().__as_proxied__()
8774
models: resources.Models = ModelsProxy().__as_proxied__()
8875
embeddings: resources.Embeddings = EmbeddingsProxy().__as_proxied__()
89-
fine_tunes: resources.FineTunes = FineTunesProxy().__as_proxied__()
9076
completions: resources.Completions = CompletionsProxy().__as_proxied__()
9177
moderations: resources.Moderations = ModerationsProxy().__as_proxied__()
9278
fine_tuning: resources.FineTuning = FineTuningProxy().__as_proxied__()

src/openai/resources/__init__.py

-10
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
from .beta import Beta, AsyncBeta, BetaWithRawResponse, AsyncBetaWithRawResponse
44
from .chat import Chat, AsyncChat, ChatWithRawResponse, AsyncChatWithRawResponse
55
from .audio import Audio, AsyncAudio, AudioWithRawResponse, AsyncAudioWithRawResponse
6-
from .edits import Edits, AsyncEdits, EditsWithRawResponse, AsyncEditsWithRawResponse
76
from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
87
from .images import Images, AsyncImages, ImagesWithRawResponse, AsyncImagesWithRawResponse
98
from .models import Models, AsyncModels, ModelsWithRawResponse, AsyncModelsWithRawResponse
109
from .embeddings import Embeddings, AsyncEmbeddings, EmbeddingsWithRawResponse, AsyncEmbeddingsWithRawResponse
11-
from .fine_tunes import FineTunes, AsyncFineTunes, FineTunesWithRawResponse, AsyncFineTunesWithRawResponse
1210
from .completions import Completions, AsyncCompletions, CompletionsWithRawResponse, AsyncCompletionsWithRawResponse
1311
from .fine_tuning import FineTuning, AsyncFineTuning, FineTuningWithRawResponse, AsyncFineTuningWithRawResponse
1412
from .moderations import Moderations, AsyncModerations, ModerationsWithRawResponse, AsyncModerationsWithRawResponse
@@ -22,10 +20,6 @@
2220
"AsyncChat",
2321
"ChatWithRawResponse",
2422
"AsyncChatWithRawResponse",
25-
"Edits",
26-
"AsyncEdits",
27-
"EditsWithRawResponse",
28-
"AsyncEditsWithRawResponse",
2923
"Embeddings",
3024
"AsyncEmbeddings",
3125
"EmbeddingsWithRawResponse",
@@ -54,10 +48,6 @@
5448
"AsyncFineTuning",
5549
"FineTuningWithRawResponse",
5650
"AsyncFineTuningWithRawResponse",
57-
"FineTunes",
58-
"AsyncFineTunes",
59-
"FineTunesWithRawResponse",
60-
"AsyncFineTunesWithRawResponse",
6151
"Beta",
6252
"AsyncBeta",
6353
"BetaWithRawResponse",

src/openai/resources/chat/completions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def create(
185185
will not call a function and instead generates a message. `auto` means the model
186186
can pick between generating a message or calling a function. Specifying a
187187
particular function via
188-
`{"type: "function", "function": {"name": "my_function"}}` forces the model to
188+
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
189189
call that function.
190190
191191
`none` is the default when no functions are present. `auto` is the default if
@@ -371,7 +371,7 @@ def create(
371371
will not call a function and instead generates a message. `auto` means the model
372372
can pick between generating a message or calling a function. Specifying a
373373
particular function via
374-
`{"type: "function", "function": {"name": "my_function"}}` forces the model to
374+
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
375375
call that function.
376376
377377
`none` is the default when no functions are present. `auto` is the default if
@@ -557,7 +557,7 @@ def create(
557557
will not call a function and instead generates a message. `auto` means the model
558558
can pick between generating a message or calling a function. Specifying a
559559
particular function via
560-
`{"type: "function", "function": {"name": "my_function"}}` forces the model to
560+
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
561561
call that function.
562562
563563
`none` is the default when no functions are present. `auto` is the default if
@@ -833,7 +833,7 @@ async def create(
833833
will not call a function and instead generates a message. `auto` means the model
834834
can pick between generating a message or calling a function. Specifying a
835835
particular function via
836-
`{"type: "function", "function": {"name": "my_function"}}` forces the model to
836+
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
837837
call that function.
838838
839839
`none` is the default when no functions are present. `auto` is the default if
@@ -1019,7 +1019,7 @@ async def create(
10191019
will not call a function and instead generates a message. `auto` means the model
10201020
can pick between generating a message or calling a function. Specifying a
10211021
particular function via
1022-
`{"type: "function", "function": {"name": "my_function"}}` forces the model to
1022+
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
10231023
call that function.
10241024
10251025
`none` is the default when no functions are present. `auto` is the default if
@@ -1205,7 +1205,7 @@ async def create(
12051205
will not call a function and instead generates a message. `auto` means the model
12061206
can pick between generating a message or calling a function. Specifying a
12071207
particular function via
1208-
`{"type: "function", "function": {"name": "my_function"}}` forces the model to
1208+
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
12091209
call that function.
12101210
12111211
`none` is the default when no functions are present. `auto` is the default if

0 commit comments

Comments
 (0)