Skip to content

Commit 21976bb

Browse files
refactor(platform): Standardize token usage
- Code refactor
1 parent e2e9a04 commit 21976bb

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

src/platform/src/Result/Metadata/TokenUsage.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@
1313

1414
/**
1515
* @author Junaid Farooq <[email protected]>
16-
*
17-
* @phpstan-type TokenUsageArray array{
18-
* prompt_tokens: ?int,
19-
* completion_tokens: ?int,
20-
* thinking_tokens: ?int,
21-
* cached_tokens: ?int,
22-
* remaining_tokens: ?int,
23-
* remaining_tokens_minute: ?int,
24-
* remaining_tokens_month: ?int,
25-
* total_tokens: ?int,
26-
* }
2716
*/
2817
final class TokenUsage implements \JsonSerializable
2918
{
@@ -40,9 +29,18 @@ public function __construct(
4029
}
4130

4231
/**
43-
* @return TokenUsageArray
32+
* @return array{
33+
* prompt_tokens: ?int,
34+
* completion_tokens: ?int,
35+
* thinking_tokens: ?int,
36+
* cached_tokens: ?int,
37+
* remaining_tokens: ?int,
38+
* remaining_tokens_minute: ?int,
39+
* remaining_tokens_month: ?int,
40+
* total_tokens: ?int,
41+
* }
4442
*/
45-
public function toArray(): array
43+
public function jsonSerialize(): array
4644
{
4745
return [
4846
'prompt_tokens' => $this->promptTokens,
@@ -55,12 +53,4 @@ public function toArray(): array
5553
'total_tokens' => $this->totalTokens,
5654
];
5755
}
58-
59-
/**
60-
* @return TokenUsageArray
61-
*/
62-
public function jsonSerialize(): array
63-
{
64-
return $this->toArray();
65-
}
6656
}

0 commit comments

Comments
 (0)