Skip to content

Commit 1d073b2

Browse files
committed
handle 0 values correctly
1 parent 66fe942 commit 1d073b2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Providers/Anthropic/Handlers/AnthropicHandlerAbstract.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ protected function processRateLimits(): array
119119

120120
return new ProviderRateLimit(
121121
name: $limit_name,
122-
limit: data_get($fields, 'limit')
122+
limit: data_get($fields, 'limit') !== null
123123
? (int) data_get($fields, 'limit')
124124
: null,
125-
remaining: data_get($fields, 'remaining')
125+
remaining: data_get($fields, 'remaining') !== null
126126
? (int) data_get($fields, 'remaining')
127127
: null,
128-
resetsAt: data_get($fields, 'reset') ? new Carbon($resets_at) : null
128+
resetsAt: data_get($fields, 'reset') !== null ? new Carbon($resets_at) : null
129129
);
130130
}));
131131
}

tests/Providers/Anthropic/AnthropicRateLimitExceptionTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@
5757
expect($e->rateLimits[0]->limit)->toEqual(1000);
5858
expect($e->rateLimits[0]->remaining)->toEqual(500);
5959
expect($e->rateLimits[0]->resetsAt)->toEqual($requests_reset);
60+
61+
expect($e->rateLimits[1]->name)->toEqual('input-tokens');
62+
expect($e->rateLimits[1]->limit)->toEqual(80000);
63+
expect($e->rateLimits[1]->remaining)->toEqual(0);
6064
}
6165
});

0 commit comments

Comments
 (0)