Skip to content

Commit a3b4e44

Browse files
authored
Merge pull request #499 from openai-php/fix-fine-tuning-job-response-error
Finetuning job response: error is sometimes present but empty
2 parents 5c59196 + 9671194 commit a3b4e44

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Responses/FineTuning/RetrieveJobResponse.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private function __construct(
4848
/**
4949
* Acts as static factory, and returns a new Response instance.
5050
*
51-
* @param array{id: string, object: string, model: string, created_at: int, finished_at: ?int, fine_tuned_model: ?string, hyperparameters: array{n_epochs: int|string, batch_size: int|string|null, learning_rate_multiplier: float|string|null}, organization_id: string, result_files: array<int, string>, status: string, validation_file: ?string, training_file: string, trained_tokens: ?int, error: ?array{code: string, param: ?string, message: string}} $attributes
51+
* @param array{id: string, object: string, model: string, created_at: int, finished_at: ?int, fine_tuned_model: ?string, hyperparameters: array{n_epochs: int|string, batch_size: int|string|null, learning_rate_multiplier: float|string|null}, organization_id: string, result_files: array<int, string>, status: string, validation_file: ?string, training_file: string, trained_tokens: ?int, error: ?array{code?: string, param?: ?string, message?: string}} $attributes
5252
*/
5353
public static function from(array $attributes, MetaInformation $meta): self
5454
{
@@ -66,7 +66,12 @@ public static function from(array $attributes, MetaInformation $meta): self
6666
$attributes['validation_file'],
6767
$attributes['training_file'],
6868
$attributes['trained_tokens'],
69-
isset($attributes['error']) ? RetrieveJobResponseError::from($attributes['error']) : null,
69+
(
70+
isset($attributes['error']) &&
71+
isset($attributes['error']['code']) &&
72+
isset($attributes['error']['param']) &&
73+
isset($attributes['error']['message'])
74+
) ? RetrieveJobResponseError::from($attributes['error']) : null,
7075
$meta,
7176
);
7277
}

src/Responses/FineTuning/RetrieveJobResponseError.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ private function __construct(
3131
public static function from(array $attributes): ?self
3232
{
3333
return new self(
34-
$attributes['code']??"",
35-
$attributes['param']??null,
36-
$attributes['message']??"",
34+
$attributes['code'],
35+
$attributes['param'],
36+
$attributes['message'],
3737
);
3838
}
3939

0 commit comments

Comments
 (0)