Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit aa321d5

Browse files
Merge pull request #35 from tectalichq/feature/1.6.0
v1.6.0 Release: Adds new fine-tuning API
2 parents 434f48f + b4aaca2 commit aa321d5

File tree

127 files changed

+6489
-2312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+6489
-2312
lines changed

CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,55 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 1.6.0 - 2023-09-06
9+
10+
### Added
11+
- Add support for OpenAI's new **fine-tuning** API, which allows fine-tuning of GPT 3.5 Turbo. [Fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning). [Announcement](https://openai.com/blog/gpt-3-5-turbo-fine-tuning-and-api-updates).
12+
- Add new `FineTuningJobs` Handler, which creates and lists fine-tuning jobs.
13+
- Add new `FineTuningJobsEvents` Handler, which gets status updates for a given fine-tuning job.
14+
- Add new `FineTuningJobsCancel` Handler, which cancels an existing fine-tuning job.
15+
- Add support for new content moderation categories: `harassment/threatening`, `self-harm/intent`, `self-harm/instructions`. [Moderation guide](https://platform.openai.com/docs/guides/moderation).
16+
17+
### Changed
18+
- The `\Tectalic\OpenAi\Models\ChatCompletions\CreateRequestFunctionsItem::$parameters` property is now required.
19+
- The `\Tectalic\OpenAi\Models\ChatCompletions\CreateRequestMessagesItem::$content` property is now required.
20+
- The `\Tectalic\OpenAi\Models\ChatCompletions\CreateRequestMessagesItemFunctionCall` `name` and `arguments` properties are now required.
21+
- The `\Tectalic\OpenAi\Models\ChatCompletions\CreateResponseChoicesItem` `index`, `message` and `finish_reason` properties are now required.
22+
- The `\Tectalic\OpenAi\Models\ChatCompletions\CreateResponseChoicesItemMessage::$content` property is now required.
23+
- The `\Tectalic\OpenAi\Models\ChatCompletions\CreateResponseChoicesItemMessageFunctionCall` `name` and `arguments` properties are now required.
24+
- The `\Tectalic\OpenAi\Models\Edits\CreateResponseChoicesItem` `text`, `index` and `finish_reason` properties are now required.
25+
- The `\Tectalic\OpenAi\Models\Edits\CreateResponseChoicesItem::$logprobs` property has been removed.
26+
- The `\Tectalic\OpenAi\Models\Files\CreateResponse::$format` property is now required.
27+
- The `\Tectalic\OpenAi\Models\Files\ListResponseDataItem::$format` property is now required.
28+
- The `\Tectalic\OpenAi\Models\Files\RetrieveResponse::$format` property is now required.
29+
- The `\Tectalic\OpenAi\Models\FineTunes\CreateResponseHyperparams` model structure is now defined, with the following required properties: `n_epochs`, `batch_size`, `prompt_loss_weight` and `learning_rate_multiplier`.
30+
- The `\Tectalic\OpenAi\Models\FineTunes\CreateResponseResultFilesItem::$format` property is now required.
31+
- The `\Tectalic\OpenAi\Models\FineTunes\CreateResponseTrainingFilesItem::$format` property is now required.
32+
- The `\Tectalic\OpenAi\Models\FineTunes\CreateResponseValidationFilesItem::$format` property is now required.
33+
- The `\Tectalic\OpenAi\Models\FineTunes\ListResponseDataItemHyperparams` model structure is now defined, with the following required properties: `n_epochs`, `batch_size`, `prompt_loss_weight` and `learning_rate_multiplier`.
34+
- The `\Tectalic\OpenAi\Models\FineTunes\ListResponseDataItemResultFilesItem::$format` property is now required.
35+
- The `\Tectalic\OpenAi\Models\FineTunes\ListResponseDataItemTrainingFilesItem::$format` property is now required.
36+
- The `\Tectalic\OpenAi\Models\FineTunes\ListResponseDataItemValidationFilesItem::$format` property is now required.
37+
- The `\Tectalic\OpenAi\Models\FineTunes\RetrieveResponseHyperparams` model structure is now defined, with the following required properties: `n_epochs`, `batch_size`, `prompt_loss_weight` and `learning_rate_multiplier`.
38+
- The `\Tectalic\OpenAi\Models\FineTunes\RetrieveResponseResultFilesItem::$format` property is now required.
39+
- The `\Tectalic\OpenAi\Models\FineTunes\RetrieveResponseTrainingFilesItem::$format` property is now required.
40+
- The `\Tectalic\OpenAi\Models\FineTunes\RetrieveResponseValidationFilesItem::$format` property is now required.
41+
- The `\Tectalic\OpenAi\Models\FineTunes\RetrieveResponseValidationFilesItem::$format` property is now required.
42+
- The `\Tectalic\OpenAi\Models\FineTunesCancel\CancelFineTuneResponseHyperparams` model structure is now defined, with the following required properties: `n_epochs`, `batch_size`, `prompt_loss_weight` and `learning_rate_multiplier`.
43+
- The `\Tectalic\OpenAi\Models\FineTunesCancel\CancelFineTuneResponseResultFilesItem::$format` property is now required.
44+
- The `\Tectalic\OpenAi\Models\FineTunesCancel\CancelFineTuneResponseTrainingFilesItem::$format` property is now required.
45+
- The `\Tectalic\OpenAi\Models\FineTunesCancel\CancelFineTuneResponseValidationFilesItem::$format` property is now required.
46+
- The `\Tectalic\OpenAi\Models\Moderations\CreateResponseResultsItemCategories` model now supports `harassment/threatening`, `self-harm/intent`, `self-harm/instructions` information.
47+
- The `\Tectalic\OpenAi\Models\Moderations\CreateResponseResultsItemCategoryScores` model now supports `harassment/threatening`, `self-harm/intent`, `self-harm/instructions` information.
48+
- Improved documentation for many model properties.
49+
- API version updated from 1.3.1 to 2.0.0.
50+
51+
### Deprecated
52+
- Deprecate the `Edits` Handler. The `ChatCompletions` handler should be used instead. These endpoints will be shut down on January 04, 2024.
53+
- Deprecate the `FineTunes` Handler. The new `FineTunesJobs` handler should be used instead. These endpoints will be shut down on January 04, 2024.
54+
- Deprecate the `FineTunesEvents` Handler. The new `FineTunesJobsEvents` handler should be used instead. These endpoints will be shut down on January 04, 2024.
55+
- Deprecate the `FineTunesCancel` Handler. The new `FineTunesJobsCancel` handler should be used instead. These endpoints will be shut down on January 04, 2024.
56+
857
## 1.5.0 - 2023-06-19
958

1059
### Added

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The **Tectalic OpenAI REST API Client** is a package that provides a convenient and straightforward way to interact with the **OpenAI API** from your PHP application.
66

7-
Supports **ChatGPT**, **GPT-4**, **GPT-3.5**, **GPT-3**, **Codex**, **DALL·E**, **Whisper**, **Embeddings** and **Moderation** models, with fully typed Data Transfer Objects (DTOs) for all requests and responses and IDE autocomplete support.
7+
Supports **ChatGPT**, **GPT-4**, **GPT-3.5**, **GPT-3**, **Codex**, **DALL·E**, **Whisper**, **Fine-Tuning**, **Embeddings** and **Moderation** models, with fully typed Data Transfer Objects (DTOs) for all requests and responses and IDE autocomplete support.
88

99
More information is available from [https://tectalic.com/apis/openai](https://tectalic.com/apis/openai).
1010

@@ -291,43 +291,50 @@ In the **Usage** code above, customize the `Authentication` constructor to your
291291

292292
The primary class you will interact with is the `Client` class (`Tectalic\OpenAi\Client`).
293293

294-
This `Client` class also contains the helper methods that let you quickly access the 16 API Handlers.
294+
This `Client` class also contains the helper methods that let you quickly access the 19 API Handlers.
295295

296296
Please see below for a complete list of supported handlers and methods.
297297

298298
### Supported API Handlers and Methods
299299

300-
This package supports 23 API Methods, which are grouped into 16 API Handlers.
300+
This package supports 28 API Methods, which are grouped into 19 API Handlers.
301301

302302
See the table below for a full list of API Handlers and Methods.
303303

304304

305305
| API Handler Class and Method Name | Description | API Verb and URL |
306306
| --------------------------------- | ----------- | ---------------- |
307307
|`AudioTranscriptions::create()`|Transcribes audio into the input language.|`POST` `/audio/transcriptions`|
308-
|`AudioTranslations::create()`|Translates audio into into English.|`POST` `/audio/translations`|
308+
|`AudioTranslations::create()`|Translates audio into English.|`POST` `/audio/translations`|
309309
|`ChatCompletions::create()`|Creates a model response for the given chat conversation.|`POST` `/chat/completions`|
310310
|`Completions::create()`|Creates a completion for the provided prompt and parameters.|`POST` `/completions`|
311-
|`Edits::create()`|Creates a new edit for the provided input, instruction, and parameters.|`POST` `/edits`|
311+
|~~`Edits::create()`~~|~~Creates a new edit for the provided input, instruction, and parameters.~~|~~`POST` `/edits`~~|
312312
|`Embeddings::create()`|Creates an embedding vector representing the input text.|`POST` `/embeddings`|
313313
|`Files::list()`|Returns a list of files that belong to the user's organization.|`GET` `/files`|
314314
|`Files::create()`|Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.|`POST` `/files`|
315315
|`Files::retrieve()`|Returns information about a specific file.|`GET` `/files/{file_id}`|
316316
|`Files::delete()`|Delete a file.|`DELETE` `/files/{file_id}`|
317-
|`FilesContent::download()`|Returns the contents of the specified file|`GET` `/files/{file_id}/content`|
318-
|`FineTunes::list()`|List your organization's fine-tuning jobs|`GET` `/fine-tunes`|
319-
|`FineTunes::create()`|Creates a job that fine-tunes a specified model from a given dataset.<br />Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.<br />Learn more about Fine-tuning|`POST` `/fine-tunes`|
320-
|`FineTunes::retrieve()`|Gets info about the fine-tune job.<br />Learn more about Fine-tuning|`GET` `/fine-tunes/{fine_tune_id}`|
321-
|`FineTunesCancel::cancelFineTune()`|Immediately cancel a fine-tune job.|`POST` `/fine-tunes/{fine_tune_id}/cancel`|
322-
|`FineTunesEvents::listFineTune()`|Get fine-grained status updates for a fine-tune job.|`GET` `/fine-tunes/{fine_tune_id}/events`|
317+
|`FilesContent::download()`|Returns the contents of the specified file.|`GET` `/files/{file_id}/content`|
318+
|~~`FineTunes::list()`~~|~~List your organization's fine-tuning jobs~~|~~`GET` `/fine-tunes`~~|
319+
|~~`FineTunes::create()`~~|~~Creates a job that fine-tunes a specified model from a given dataset.<br />Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.<br />Learn more about fine-tuning~~|~~`POST` `/fine-tunes`~~|
320+
|~~`FineTunes::retrieve()`~~|~~Gets info about the fine-tune job.<br />Learn more about fine-tuning~~|~~`GET` `/fine-tunes/{fine_tune_id}`~~|
321+
|~~`FineTunesCancel::cancelFineTune()`~~|~~Immediately cancel a fine-tune job.~~|~~`POST` `/fine-tunes/{fine_tune_id}/cancel`~~|
322+
|~~`FineTunesEvents::listFineTune()`~~|~~Get fine-grained status updates for a fine-tune job.~~|~~`GET` `/fine-tunes/{fine_tune_id}/events`~~|
323+
|`FineTuningJobs::listPaginated()`|List your organization's fine-tuning jobs|`GET` `/fine_tuning/jobs`|
324+
|`FineTuningJobs::create()`|Creates a job that fine-tunes a specified model from a given dataset.<br />Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.<br />Learn more about fine-tuning|`POST` `/fine_tuning/jobs`|
325+
|`FineTuningJobs::retrieve()`|Get info about a fine-tuning job.<br />Learn more about fine-tuning|`GET` `/fine_tuning/jobs/{fine_tuning_job_id}`|
326+
|`FineTuningJobsCancel::fineTuning()`|Immediately cancel a fine-tune job.|`POST` `/fine_tuning/jobs/{fine_tuning_job_id}/cancel`|
327+
|`FineTuningJobsEvents::listFineTuning()`|Get status updates for a fine-tuning job.|`GET` `/fine_tuning/jobs/{fine_tuning_job_id}/events`|
323328
|`ImagesEdits::createImage()`|Creates an edited or extended image given an original image and a prompt.|`POST` `/images/edits`|
324329
|`ImagesGenerations::create()`|Creates an image given a prompt.|`POST` `/images/generations`|
325330
|`ImagesVariations::createImage()`|Creates a variation of a given image.|`POST` `/images/variations`|
326331
|`Models::list()`|Lists the currently available models, and provides basic information about each one such as the owner and availability.|`GET` `/models`|
327332
|`Models::retrieve()`|Retrieves a model instance, providing basic information about the model such as the owner and permissioning.|`GET` `/models/{model}`|
328-
|`Models::delete()`|Delete a fine-tuned model. You must have the Owner role in your organization.|`DELETE` `/models/{model}`|
333+
|`Models::delete()`|Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.|`DELETE` `/models/{model}`|
329334
|`Moderations::create()`|Classifies if text violates OpenAI's Content Policy|`POST` `/moderations`|
330335

336+
Deprecated method(s) are listed with ~~strike-through~~ formatting. Please do not use these methods, as they will be removed in a future release.
337+
331338
### Making a Request
332339

333340
There are two ways to make a request to the nominated API Handler and API Method:

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tectalic/openai",
3-
"description": "An OpenAI REST API Client with support for ChatGPT, GPT-4, GPT-3.5, GPT-3, Codex, DALL·E, Whisper, Embeddings and Moderation models. Includes fully typed Data Transfer Objects (DTOs) for all requests and responses and IDE autocomplete support.",
3+
"description": "An OpenAI REST API Client with support for ChatGPT, GPT-4, GPT-3.5, GPT-3, Codex, DALL·E, Whisper, Embeddings, Fine-Tuning and Moderation models. Includes fully typed Data Transfer Objects (DTOs) for all requests and responses and IDE autocomplete support.",
44
"type": "library",
55
"license": "MIT",
66
"keywords": [
@@ -9,6 +9,7 @@
99
"chatgpt",
1010
"dalle",
1111
"dall-e",
12+
"fine-tuning",
1213
"gpt-3",
1314
"gpt-3.5",
1415
"gpt-4",

manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"libraryVersion": "1.5.0",
3-
"apiVersion": "1.3.1",
4-
"buildVersion": "1.2.1"
2+
"libraryVersion": "1.6.0",
3+
"apiVersion": "2.0.0",
4+
"buildVersion": "1.2.2"
55
}

src/Client.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
use Tectalic\OpenAi\Handlers\FineTunes;
3232
use Tectalic\OpenAi\Handlers\FineTunesCancel;
3333
use Tectalic\OpenAi\Handlers\FineTunesEvents;
34+
use Tectalic\OpenAi\Handlers\FineTuningJobs;
35+
use Tectalic\OpenAi\Handlers\FineTuningJobsCancel;
36+
use Tectalic\OpenAi\Handlers\FineTuningJobsEvents;
3437
use Tectalic\OpenAi\Handlers\ImagesEdits;
3538
use Tectalic\OpenAi\Handlers\ImagesGenerations;
3639
use Tectalic\OpenAi\Handlers\ImagesVariations;
@@ -96,6 +99,8 @@ public function completions(): Completions
9699
/**
97100
* Access to the edits handler.
98101
*
102+
* @deprecated
103+
*
99104
* @api
100105
* @return Edits
101106
*/
@@ -192,9 +197,44 @@ public function filesContent(): FilesContent
192197
return new \Tectalic\OpenAi\Handlers\FilesContent($this);
193198
}
194199

200+
/**
201+
* Access to the fineTuningJobs handler.
202+
*
203+
* @api
204+
* @return FineTuningJobs
205+
*/
206+
public function fineTuningJobs(): FineTuningJobs
207+
{
208+
return new \Tectalic\OpenAi\Handlers\FineTuningJobs($this);
209+
}
210+
211+
/**
212+
* Access to the fineTuningJobsEvents handler.
213+
*
214+
* @api
215+
* @return FineTuningJobsEvents
216+
*/
217+
public function fineTuningJobsEvents(): FineTuningJobsEvents
218+
{
219+
return new \Tectalic\OpenAi\Handlers\FineTuningJobsEvents($this);
220+
}
221+
222+
/**
223+
* Access to the fineTuningJobsCancel handler.
224+
*
225+
* @api
226+
* @return FineTuningJobsCancel
227+
*/
228+
public function fineTuningJobsCancel(): FineTuningJobsCancel
229+
{
230+
return new \Tectalic\OpenAi\Handlers\FineTuningJobsCancel($this);
231+
}
232+
195233
/**
196234
* Access to the fineTunes handler.
197235
*
236+
* @deprecated
237+
*
198238
* @api
199239
* @return FineTunes
200240
*/
@@ -206,6 +246,8 @@ public function fineTunes(): FineTunes
206246
/**
207247
* Access to the fineTunesCancel handler.
208248
*
249+
* @deprecated
250+
*
209251
* @api
210252
* @return FineTunesCancel
211253
*/
@@ -217,6 +259,8 @@ public function fineTunesCancel(): FineTunesCancel
217259
/**
218260
* Access to the fineTunesEvents handler.
219261
*
262+
* @deprecated
263+
*
220264
* @api
221265
* @return FineTunesEvents
222266
*/
@@ -406,7 +450,7 @@ private function mergeRequestParts(
406450

407451
$request = $request->withHeader(
408452
'User-Agent',
409-
'Tectalic OpenAI REST API Client/1.5.0'
453+
'Tectalic OpenAI REST API Client/1.6.0'
410454
);
411455

412456
// Merge Headers.

src/Handlers/AudioTranslations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(?Client $client = null)
4343
}
4444

4545
/**
46-
* Translates audio into into English.
46+
* Translates audio into English.
4747
*
4848
* Operation URL: POST /audio/translations
4949
* Operation ID: createTranslation

src/Handlers/Edits.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Tectalic\OpenAi\Models\Edits\CreateResponse;
2424
use Throwable;
2525

26+
/**
27+
* @deprecated
28+
*/
2629
final class Edits
2730
{
2831
/** @var Client */
@@ -50,6 +53,8 @@ public function __construct(?Client $client = null)
5053
*
5154
* @param CreateRequest|array $body
5255
*
56+
* @deprecated
57+
*
5358
* @api
5459
* @return self
5560
*/

src/Handlers/Files.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function create($body): self
9898
* Operation URL: GET /files/{file_id}
9999
* Operation ID: retrieveFile
100100
*
101-
* @param string $fileId The ID of the file to use for this request
101+
* @param string $fileId The ID of the file to use for this request.
102102
*
103103
* @api
104104
* @return self
@@ -121,7 +121,7 @@ public function retrieve($fileId): self
121121
* Operation URL: DELETE /files/{file_id}
122122
* Operation ID: deleteFile
123123
*
124-
* @param string $fileId The ID of the file to use for this request
124+
* @param string $fileId The ID of the file to use for this request.
125125
*
126126
* @api
127127
* @return self

src/Handlers/FilesContent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public function __construct(?Client $client = null)
4242
}
4343

4444
/**
45-
* Returns the contents of the specified file
45+
* Returns the contents of the specified file.
4646
*
4747
* Operation URL: GET /files/{file_id}/content
4848
* Operation ID: downloadFile
4949
*
50-
* @param string $fileId The ID of the file to use for this request
50+
* @param string $fileId The ID of the file to use for this request.
5151
*
5252
* @api
5353
* @return self

src/Handlers/FineTunes.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
use Tectalic\OpenAi\Models\FineTunes\RetrieveResponse;
2626
use Throwable;
2727

28+
/**
29+
* @deprecated
30+
*/
2831
final class FineTunes
2932
{
3033
/** @var Client */
@@ -50,6 +53,8 @@ public function __construct(?Client $client = null)
5053
* Operation URL: GET /fine-tunes
5154
* Operation ID: listFineTunes
5255
*
56+
* @deprecated
57+
*
5358
* @api
5459
* @return self
5560
*/
@@ -69,13 +74,15 @@ public function list(): self
6974
* Creates a job that fine-tunes a specified model from a given dataset.
7075
* Response includes details of the enqueued job including job status and the name
7176
* of the fine-tuned models once complete.
72-
* Learn more about Fine-tuning
77+
* Learn more about fine-tuning
7378
*
7479
* Operation URL: POST /fine-tunes
7580
* Operation ID: createFineTune
7681
*
7782
* @param CreateRequest|array $body
7883
*
84+
* @deprecated
85+
*
7986
* @api
8087
* @return self
8188
*/
@@ -93,13 +100,15 @@ public function create($body): self
93100

94101
/**
95102
* Gets info about the fine-tune job.
96-
* Learn more about Fine-tuning
103+
* Learn more about fine-tuning
97104
*
98105
* Operation URL: GET /fine-tunes/{fine_tune_id}
99106
* Operation ID: retrieveFineTune
100107
*
101108
* @param string $fineTuneId The ID of the fine-tune job
102109
*
110+
* @deprecated
111+
*
103112
* @api
104113
* @return self
105114
*/

0 commit comments

Comments
 (0)