Skip to content

Provide default image reponse usage values, if they are not returned by the API #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Responses/Images/ImageResponseUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
public static function from(array $attributes): self
{
return new self(
$attributes['total_tokens'],
$attributes['input_tokens'],
$attributes['output_tokens'],
ImageResponseUsageInputTokensDetails::from($attributes['input_tokens_details']),
$attributes['total_tokens'] ?? 0,

Check failure on line 22 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-stable

Offset 'total_tokens' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.

Check failure on line 22 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-lowest

Offset 'total_tokens' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.
$attributes['input_tokens'] ?? 0,

Check failure on line 23 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-stable

Offset 'input_tokens' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.

Check failure on line 23 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-lowest

Offset 'input_tokens' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.
$attributes['output_tokens'] ?? 0,

Check failure on line 24 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-stable

Offset 'output_tokens' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.

Check failure on line 24 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-lowest

Offset 'output_tokens' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.
ImageResponseUsageInputTokensDetails::from($attributes['input_tokens_details'] ?? []),

Check failure on line 25 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-stable

Offset 'input_tokens_details' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.

Check failure on line 25 in src/Responses/Images/ImageResponseUsage.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-lowest

Offset 'input_tokens_details' on array{total_tokens: int, input_tokens: int, output_tokens: int, input_tokens_details: array{text_tokens: int, image_tokens: int}} on left side of ?? always exists and is not nullable.
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Responses/Images/ImageResponseUsageInputTokensDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
public static function from(array $attributes): self
{
return new self(
$attributes['text_tokens'],
$attributes['image_tokens'],
$attributes['text_tokens'] ?? 0,

Check failure on line 20 in src/Responses/Images/ImageResponseUsageInputTokensDetails.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-stable

Offset 'text_tokens' on array{text_tokens: int, image_tokens: int} on left side of ?? always exists and is not nullable.

Check failure on line 20 in src/Responses/Images/ImageResponseUsageInputTokensDetails.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-lowest

Offset 'text_tokens' on array{text_tokens: int, image_tokens: int} on left side of ?? always exists and is not nullable.
$attributes['image_tokens'] ?? 0,

Check failure on line 21 in src/Responses/Images/ImageResponseUsageInputTokensDetails.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-stable

Offset 'image_tokens' on array{text_tokens: int, image_tokens: int} on left side of ?? always exists and is not nullable.

Check failure on line 21 in src/Responses/Images/ImageResponseUsageInputTokensDetails.php

View workflow job for this annotation

GitHub Actions / Formats P8.2 - ubuntu-latest - prefer-lowest

Offset 'image_tokens' on array{text_tokens: int, image_tokens: int} on left side of ?? always exists and is not nullable.
);
}

Expand Down
Loading