Skip to content

Commit 00e224e

Browse files
feat(OpenAI): add files missing expiration property (#746)
* feat files missing expiration * add expiresAt to tests * add expires_at to File.php fixture * add expires_at to fineTunes\RetrieveResponseFile * add expires_at to fineTunes\RetrieveResponseFile * composer lint * fix types
1 parent 8886359 commit 00e224e

12 files changed

Lines changed: 40 additions & 23 deletions

File tree

src/Resources/Files.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function list(array $parameters = []): ListResponse
2525
{
2626
$payload = Payload::list('files', $parameters);
2727

28-
/** @var 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>|string|null}>, first_id: ?string, last_id: ?string, has_more: ?bool}> $response */
28+
/** @var Response<array{object: string, data: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, first_id: ?string, last_id: ?string, has_more: ?bool}> $response */
2929
$response = $this->transporter->requestObject($payload);
3030

3131
return ListResponse::from($response->data(), $response->meta());
@@ -40,7 +40,7 @@ public function retrieve(string $file): RetrieveResponse
4040
{
4141
$payload = Payload::retrieve('files', $file);
4242

43-
/** @var Response<array{id: string, object: string, created_at: int, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}> $response */
43+
/** @var Response<array{id: string, object: string, created_at: int, expires_at: int|null, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}> $response */
4444
$response = $this->transporter->requestObject($payload);
4545

4646
return RetrieveResponse::from($response->data(), $response->meta());
@@ -69,7 +69,7 @@ public function upload(array $parameters): CreateResponse
6969
{
7070
$payload = Payload::upload('files', $parameters);
7171

72-
/** @var Response<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}> $response */
72+
/** @var Response<array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}> $response */
7373
$response = $this->transporter->requestObject($payload);
7474

7575
return CreateResponse::from($response->data(), $response->meta());

src/Resources/FineTunes.php

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

33-
/** @var Response<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>|string|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>|string|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>|string|null}>, updated_at: int}> $response */
33+
/** @var Response<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, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, training_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, updated_at: int}> $response */
3434
$response = $this->transporter->requestObject($payload);
3535

3636
return RetrieveResponse::from($response->data(), $response->meta());
@@ -45,7 +45,7 @@ public function list(): ListResponse
4545
{
4646
$payload = Payload::list('fine-tunes');
4747

48-
/** @var Response<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>|string|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>|string|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>|string|null}>, updated_at: int}>}> $response */
48+
/** @var Response<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, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, training_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, updated_at: int}>}> $response */
4949
$response = $this->transporter->requestObject($payload);
5050

5151
return ListResponse::from($response->data(), $response->meta());
@@ -60,7 +60,7 @@ public function retrieve(string $fineTuneId): RetrieveResponse
6060
{
6161
$payload = Payload::retrieve('fine-tunes', $fineTuneId);
6262

63-
/** @var Response<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>|string|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>|string|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>|string|null}>, updated_at: int}> $response */
63+
/** @var Response<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, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, training_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, updated_at: int}> $response */
6464
$response = $this->transporter->requestObject($payload);
6565

6666
return RetrieveResponse::from($response->data(), $response->meta());
@@ -75,7 +75,7 @@ public function cancel(string $fineTuneId): RetrieveResponse
7575
{
7676
$payload = Payload::cancel('fine-tunes', $fineTuneId);
7777

78-
/** @var Response<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>|string|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>|string|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>|string|null}>, updated_at: int}> $response */
78+
/** @var Response<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, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, status: string, validation_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, training_files: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, updated_at: int}> $response */
7979
$response = $this->transporter->requestObject($payload);
8080

8181
return RetrieveResponse::from($response->data(), $response->meta());

src/Responses/Files/CreateResponse.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
use OpenAI\Testing\Responses\Concerns\Fakeable;
1313

1414
/**
15-
* @implements ResponseContract<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
15+
* @implements ResponseContract<array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
1616
*/
1717
final class CreateResponse implements ResponseContract, ResponseHasMetaInformationContract
1818
{
1919
/**
20-
* @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
20+
* @use ArrayAccessible<array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
2121
*/
2222
use ArrayAccessible;
2323

@@ -32,6 +32,7 @@ private function __construct(
3232
public readonly string $object,
3333
public readonly int $bytes,
3434
public readonly int $createdAt,
35+
public readonly ?int $expiresAt,
3536
public readonly string $filename,
3637
public readonly string $purpose,
3738
public readonly string $status,
@@ -42,7 +43,7 @@ private function __construct(
4243
/**
4344
* Acts as static factory, and returns a new Response instance.
4445
*
45-
* @param array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null} $attributes
46+
* @param array{id: string, object: string, created_at: int, expires_at: int|null, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null} $attributes
4647
*/
4748
public static function from(array $attributes, MetaInformation $meta): self
4849
{
@@ -51,6 +52,7 @@ public static function from(array $attributes, MetaInformation $meta): self
5152
$attributes['object'],
5253
$attributes['bytes'],
5354
$attributes['created_at'],
55+
$attributes['expires_at'] ?? null,
5456
$attributes['filename'],
5557
$attributes['purpose'],
5658
$attributes['status'],
@@ -69,6 +71,7 @@ public function toArray(): array
6971
'object' => $this->object,
7072
'bytes' => $this->bytes,
7173
'created_at' => $this->createdAt,
74+
'expires_at' => $this->expiresAt,
7275
'filename' => $this->filename,
7376
'purpose' => $this->purpose,
7477
'status' => $this->status,

src/Responses/Files/ListResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function __construct(
3939
/**
4040
* Acts as static factory, and returns a new Response instance.
4141
*
42-
* @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>|string|null}>, first_id: ?string, last_id: ?string, has_more: ?bool} $attributes
42+
* @param array{object: string, data: array<int, array{id: string, object: string, created_at: int, expires_at: int|null, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>, first_id: ?string, last_id: ?string, has_more: ?bool} $attributes
4343
*/
4444
public static function from(array $attributes, MetaInformation $meta): self
4545
{

src/Responses/Files/RetrieveResponse.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
use OpenAI\Testing\Responses\Concerns\Fakeable;
1313

1414
/**
15-
* @implements ResponseContract<array{id: string, object: string, created_at: int, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
15+
* @implements ResponseContract<array{id: string, object: string, created_at: int, expires_at: int|null, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
1616
*/
1717
final class RetrieveResponse implements ResponseContract, ResponseHasMetaInformationContract
1818
{
1919
/**
20-
* @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
20+
* @use ArrayAccessible<array{id: string, object: string, created_at: int, expires_at: int|null, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>
2121
*/
2222
use ArrayAccessible;
2323

@@ -32,6 +32,7 @@ private function __construct(
3232
public readonly string $object,
3333
public readonly ?int $bytes,
3434
public readonly int $createdAt,
35+
public readonly ?int $expiresAt,
3536
public readonly string $filename,
3637
public readonly string $purpose,
3738
public readonly string $status,
@@ -42,7 +43,7 @@ private function __construct(
4243
/**
4344
* Acts as static factory, and returns a new Response instance.
4445
*
45-
* @param array{id: string, object: string, created_at: int, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null} $attributes
46+
* @param array{id: string, object: string, created_at: int, expires_at: int|null, bytes: ?int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null} $attributes
4647
*/
4748
public static function from(array $attributes, MetaInformation $meta): self
4849
{
@@ -51,6 +52,7 @@ public static function from(array $attributes, MetaInformation $meta): self
5152
$attributes['object'],
5253
$attributes['bytes'],
5354
$attributes['created_at'],
55+
$attributes['expires_at'] ?? null,
5456
$attributes['filename'],
5557
$attributes['purpose'],
5658
$attributes['status'],
@@ -69,6 +71,7 @@ public function toArray(): array
6971
'object' => $this->object,
7072
'bytes' => $this->bytes,
7173
'created_at' => $this->createdAt,
74+
'expires_at' => $this->expiresAt,
7275
'filename' => $this->filename,
7376
'purpose' => $this->purpose,
7477
'status' => $this->status,

0 commit comments

Comments
 (0)