Skip to content

Commit

Permalink
Marks Edits API as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
gehrisandro committed Aug 23, 2023
1 parent d95b3a4 commit 764559f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
61 changes: 32 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
- [Completions Resource](#completions-resource)
- [Chat Resource](#chat-resource)
- [Audio Resource](#audio-resource)
- [Edits Resource](#edits-resource)
- [Embeddings Resource](#embeddings-resource)
- [Files Resource](#files-resource)
- [FineTunes Resource](#finetunes-resource)
- [Moderations Resource](#moderations-resource)
- [Images Resource](#images-resource)
- [Edits Resource (deprecated)](#edits-resource)
- [Meta Information](#meta-information)
- [Testing](#testing)
- [Services](#services)
Expand Down Expand Up @@ -372,34 +372,6 @@ foreach ($response->segments as $segment) {
$response->toArray(); // ['task' => 'translate', ...]
```

### `Edits` Resource

#### `create`

Creates a new edit for the provided input, instruction, and parameters.

```php
$response = $client->edits()->create([
'model' => 'text-davinci-edit-001',
'input' => 'What day of the wek is it?',
'instruction' => 'Fix the spelling mistakes',
]);

$response->object; // 'edit'
$response->created; // 1589478378

foreach ($response->choices as $result) {
$result->text; // 'What day of the week is it?'
$result->index; // 0
}

$response->usage->promptTokens; // 25,
$response->usage->completionTokens; // 32,
$response->usage->totalTokens; // 57

$response->toArray(); // ['object' => 'edit', ...]
```

### `Embeddings` Resource

#### `create`
Expand Down Expand Up @@ -761,6 +733,37 @@ foreach ($response->data as $data) {
$response->toArray(); // ['created' => 1589478378, data => ['url' => 'https://oaidalleapiprodscus...', ...]]
```

### `Edits` Resource (deprecated)

> OpenAI has deprecated the Edits API and will stop working by January 4, 2024.
> https://openai.com/blog/gpt-4-api-general-availability#deprecation-of-the-edits-api
#### `create`

Creates a new edit for the provided input, instruction, and parameters.

```php
$response = $client->edits()->create([
'model' => 'text-davinci-edit-001',
'input' => 'What day of the wek is it?',
'instruction' => 'Fix the spelling mistakes',
]);

$response->object; // 'edit'
$response->created; // 1589478378

foreach ($response->choices as $result) {
$result->text; // 'What day of the week is it?'
$result->index; // 0
}

$response->usage->promptTokens; // 25,
$response->usage->completionTokens; // 32,
$response->usage->totalTokens; // 57

$response->toArray(); // ['object' => 'edit', ...]
```

## Meta Information

On all response objects you can access the meta information returned by the API via the `meta()` method.
Expand Down
3 changes: 3 additions & 0 deletions src/Contracts/Resources/EditsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface EditsContract
* @see https://platform.openai.com/docs/api-reference/edits/create
*
* @param array<string, mixed> $parameters
*
* @deprecated OpenAI has deprecated this endpoint and will stop working by January 4, 2024.
* https://openai.com/blog/gpt-4-api-general-availability#deprecation-of-the-edits-api
*/
public function create(array $parameters): CreateResponse;
}
3 changes: 3 additions & 0 deletions src/Resources/Edits.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ final class Edits implements EditsContract
* @see https://platform.openai.com/docs/api-reference/edits/create
*
* @param array<string, mixed> $parameters
*
* @deprecated OpenAI has deprecated this endpoint and will stop working by January 4, 2024.
* https://openai.com/blog/gpt-4-api-general-availability#deprecation-of-the-edits-api
*/
public function create(array $parameters): CreateResponse
{
Expand Down

0 comments on commit 764559f

Please sign in to comment.