Skip to content

Commit

Permalink
Finetuning job response: error is sometimes present but empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gehrisandro committed Nov 12, 2024
1 parent 5c59196 commit 9671194
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/Responses/FineTuning/RetrieveJobResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private function __construct(
/**
* Acts as static factory, and returns a new Response instance.
*
* @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
* @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
*/
public static function from(array $attributes, MetaInformation $meta): self
{
Expand All @@ -66,7 +66,12 @@ public static function from(array $attributes, MetaInformation $meta): self
$attributes['validation_file'],
$attributes['training_file'],
$attributes['trained_tokens'],
isset($attributes['error']) ? RetrieveJobResponseError::from($attributes['error']) : null,
(
isset($attributes['error']) &&
isset($attributes['error']['code']) &&
isset($attributes['error']['param']) &&
isset($attributes['error']['message'])
) ? RetrieveJobResponseError::from($attributes['error']) : null,
$meta,
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Responses/FineTuning/RetrieveJobResponseError.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ private function __construct(
public static function from(array $attributes): ?self
{
return new self(
$attributes['code']??"",
$attributes['param']??null,
$attributes['message']??"",
$attributes['code'],
$attributes['param'],
$attributes['message'],
);
}

Expand Down

0 comments on commit 9671194

Please sign in to comment.