Skip to content

Commit

Permalink
chore: use rps for rate limit
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Nov 29, 2024
1 parent 0f8a5a0 commit 0ab60bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/http-api-bindings/src/rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ use ratelimit::Ratelimiter;
use tabby_inference::{ChatCompletionStream, CompletionOptions, CompletionStream, Embedding};

fn new_rate_limiter(rpm: u64) -> Ratelimiter {
Ratelimiter::builder(rpm, Duration::from_secs(60))
.max_tokens(rpm)
.initial_available(rpm)
let rps = rpm / 60;
Ratelimiter::builder(rps, Duration::from_secs(1))
.max_tokens(rps)
.initial_available(rps)

Check warning on line 18 in crates/http-api-bindings/src/rate_limit.rs

View check run for this annotation

Codecov / codecov/patch

crates/http-api-bindings/src/rate_limit.rs#L15-L18

Added lines #L15 - L18 were not covered by tests
.build()
.expect("Failed to create RateLimiter, please check the HttpModelConfig.rate_limit configuration")
}
Expand Down

0 comments on commit 0ab60bc

Please sign in to comment.