Skip to content

Commit 890931f

Browse files
committed
Fix: nullable fields on FineTunes create response and add missing fields on File repsonses
1 parent a7f966e commit 890931f

File tree

15 files changed

+94
-33
lines changed

15 files changed

+94
-33
lines changed

CHANGELOG.md

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

7+
## v0.2.1 (2022-11-09)
8+
### Fixed
9+
- FineTunes create response: `batch_size`, `learning_rate` and `fine_tuned_model` are nullable (#16)
10+
- File responses: add missing fields `status` and `status_details`
11+
712
## v0.2.0 (2022-11-07)
813
### Added
914
- Add `images()` resource to interact with [DALL-E](https://beta.openai.com/docs/api-reference/images)

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ $response->bytes; // 140
236236
$response->createdAt; // 1613779657
237237
$response->filename; // 'mydata.jsonl'
238238
$response->purpose; // 'fine-tune'
239+
$response->status; // 'succeeded'
240+
$response->status_details; // null
239241

240242
$response->toArray(); // ['id' => 'file-XjGxS3KTG0uNmNOK362iJua3', ...]
241243
```
@@ -256,6 +258,8 @@ $response->bytes; // 140
256258
$response->createdAt; // 1613779657
257259
$response->filename; // 'mydata.jsonl'
258260
$response->purpose; // 'fine-tune'
261+
$response->status; // 'succeeded'
262+
$response->status_details; // null
259263

260264
$response->toArray(); // ['id' => 'file-XjGxS3KTG0uNmNOK362iJua3', ...]
261265
```
@@ -340,6 +344,8 @@ foreach ($response->resultFiles as $result) {
340344
$result->createdAt; // 1613779657
341345
$result->filename; // 'mydata.jsonl'
342346
$result->purpose; // 'fine-tune'
347+
$result->status; // 'succeeded'
348+
$result->status_details; // null
343349
}
344350

345351
foreach ($response->validationFiles as $result) {

src/Resources/Files.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function list(): ListResponse
2323
{
2424
$payload = Payload::list('files');
2525

26-
/** @var array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>} $result */
26+
/** @var array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>} $result */
2727
$result = $this->transporter->requestObject($payload);
2828

2929
return ListResponse::from($result);
@@ -38,7 +38,7 @@ public function retrieve(string $file): RetrieveResponse
3838
{
3939
$payload = Payload::retrieve('files', $file);
4040

41-
/** @var array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string} $result */
41+
/** @var array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null} $result */
4242
$result = $this->transporter->requestObject($payload);
4343

4444
return RetrieveResponse::from($result);
@@ -67,7 +67,7 @@ public function upload(array $parameters): CreateResponse
6767
{
6868
$payload = Payload::upload('files', $parameters);
6969

70-
/** @var array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string} $result */
70+
/** @var array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null} $result */
7171
$result = $this->transporter->requestObject($payload);
7272

7373
return CreateResponse::from($result);

src/Resources/FineTunes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function create(array $parameters): RetrieveResponse
2626
{
2727
$payload = Payload::create('fine-tunes', $parameters);
2828

29-
/** @var array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: string, hyperparams: array{batch_size: int, learning_rate_multiplier: float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, updated_at: int} $result */
29+
/** @var array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: ?string, hyperparams: array{batch_size: ?int, learning_rate_multiplier: ?float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, updated_at: int} $result */
3030
$result = $this->transporter->requestObject($payload);
3131

3232
return RetrieveResponse::from($result);
@@ -41,7 +41,7 @@ public function list(): ListResponse
4141
{
4242
$payload = Payload::list('fine-tunes');
4343

44-
/** @var array{object: string, data: array<int, array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: string, hyperparams: array{batch_size: int, learning_rate_multiplier: float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, updated_at: int}>} $result */
44+
/** @var array{object: string, data: array<int, array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: ?string, hyperparams: array{batch_size: ?int, learning_rate_multiplier: ?float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, updated_at: int}>} $result */
4545
$result = $this->transporter->requestObject($payload);
4646

4747
return ListResponse::from($result);
@@ -56,7 +56,7 @@ public function retrieve(string $fineTuneId): RetrieveResponse
5656
{
5757
$payload = Payload::retrieve('fine-tunes', $fineTuneId);
5858

59-
/** @var array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: string, hyperparams: array{batch_size: int, learning_rate_multiplier: float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, updated_at: int} $result */
59+
/** @var array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: ?string, hyperparams: array{batch_size: ?int, learning_rate_multiplier: ?float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, updated_at: int} $result */
6060
$result = $this->transporter->requestObject($payload);
6161

6262
return RetrieveResponse::from($result);
@@ -71,7 +71,7 @@ public function cancel(string $fineTuneId): RetrieveResponse
7171
{
7272
$payload = Payload::cancel('fine-tunes', $fineTuneId);
7373

74-
/** @var array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: string, hyperparams: array{batch_size: int, learning_rate_multiplier: float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>, updated_at: int} $result */
74+
/** @var array{id: string, object: string, model: string, created_at: int, events: array<int, array{object: string, created_at: int, level: string, message: string}>, fine_tuned_model: ?string, hyperparams: array{batch_size: ?int, learning_rate_multiplier: ?float, n_epochs: int, prompt_loss_weight: float}, organization_id: string, result_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, training_files: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>, updated_at: int} $result */
7575
$result = $this->transporter->requestObject($payload);
7676

7777
return RetrieveResponse::from($result);

src/Responses/Files/CreateResponse.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,34 @@
88
use OpenAI\Responses\Concerns\ArrayAccessible;
99

1010
/**
11-
* @implements Response<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>
11+
* @implements Response<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>
1212
*/
1313
final class CreateResponse implements Response
1414
{
1515
/**
16-
* @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>
16+
* @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>
1717
*/
1818
use ArrayAccessible;
1919

20+
/**
21+
* @param array<array-key, mixed>|null $statusDetails
22+
*/
2023
private function __construct(
2124
public readonly string $id,
2225
public readonly string $object,
2326
public readonly int $bytes,
2427
public readonly int $createdAt,
2528
public readonly string $filename,
2629
public readonly string $purpose,
30+
public readonly string $status,
31+
public readonly ?array $statusDetails,
2732
) {
2833
}
2934

3035
/**
3136
* Acts as static factory, and returns a new Response instance.
3237
*
33-
* @param array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string} $attributes
38+
* @param array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null} $attributes
3439
*/
3540
public static function from(array $attributes): self
3641
{
@@ -41,6 +46,8 @@ public static function from(array $attributes): self
4146
$attributes['created_at'],
4247
$attributes['filename'],
4348
$attributes['purpose'],
49+
$attributes['status'],
50+
$attributes['status_details'],
4451
);
4552
}
4653

@@ -56,6 +63,8 @@ public function toArray(): array
5663
'created_at' => $this->createdAt,
5764
'filename' => $this->filename,
5865
'purpose' => $this->purpose,
66+
'status' => $this->status,
67+
'status_details' => $this->statusDetails,
5968
];
6069
}
6170
}

src/Responses/Files/ListResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
use OpenAI\Responses\Concerns\ArrayAccessible;
99

1010
/**
11-
* @implements Response<array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>}>
11+
* @implements Response<array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>}>
1212
*/
1313
final class ListResponse implements Response
1414
{
1515
/**
16-
* @use ArrayAccessible<array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>}>
16+
* @use ArrayAccessible<array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>}>
1717
*/
1818
use ArrayAccessible;
1919

@@ -29,7 +29,7 @@ private function __construct(
2929
/**
3030
* Acts as static factory, and returns a new Response instance.
3131
*
32-
* @param array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>} $attributes
32+
* @param array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>} $attributes
3333
*/
3434
public static function from(array $attributes): self
3535
{

src/Responses/Files/RetrieveResponse.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,34 @@
88
use OpenAI\Responses\Concerns\ArrayAccessible;
99

1010
/**
11-
* @implements Response<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>
11+
* @implements Response<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>
1212
*/
1313
final class RetrieveResponse implements Response
1414
{
1515
/**
16-
* @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string}>
16+
* @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null}>
1717
*/
1818
use ArrayAccessible;
1919

20+
/**
21+
* @param array<array-key, mixed>|null $statusDetails
22+
*/
2023
private function __construct(
2124
public readonly string $id,
2225
public readonly string $object,
2326
public readonly int $bytes,
2427
public readonly int $createdAt,
2528
public readonly string $filename,
2629
public readonly string $purpose,
30+
public readonly string $status,
31+
public readonly ?array $statusDetails,
2732
) {
2833
}
2934

3035
/**
3136
* Acts as static factory, and returns a new Response instance.
3237
*
33-
* @param array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string} $attributes
38+
* @param array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|null} $attributes
3439
*/
3540
public static function from(array $attributes): self
3641
{
@@ -41,6 +46,8 @@ public static function from(array $attributes): self
4146
$attributes['created_at'],
4247
$attributes['filename'],
4348
$attributes['purpose'],
49+
$attributes['status'],
50+
$attributes['status_details'],
4451
);
4552
}
4653

@@ -56,6 +63,8 @@ public function toArray(): array
5663
'created_at' => $this->createdAt,
5764
'filename' => $this->filename,
5865
'purpose' => $this->purpose,
66+
'status' => $this->status,
67+
'status_details' => $this->statusDetails,
5968
];
6069
}
6170
}

0 commit comments

Comments
 (0)