From 3d902968d1a56399bf2b9d2d762e04bcce261c09 Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Mon, 25 Nov 2024 11:00:55 +0800 Subject: [PATCH] chore: use serde default for rate limit --- crates/http-api-bindings/src/embedding/mod.rs | 7 ++----- crates/tabby-common/src/config.rs | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/http-api-bindings/src/embedding/mod.rs b/crates/http-api-bindings/src/embedding/mod.rs index 1d6e3cb3d333..d5b8920af72f 100644 --- a/crates/http-api-bindings/src/embedding/mod.rs +++ b/crates/http-api-bindings/src/embedding/mod.rs @@ -8,16 +8,13 @@ use std::sync::Arc; use llama::LlamaCppEngine; use rate_limit::RateLimitedEmbedding; -use tabby_common::config::{HttpModelConfig, RateLimit}; +use tabby_common::config::HttpModelConfig; use tabby_inference::Embedding; use self::{openai::OpenAIEmbeddingEngine, voyage::VoyageEmbeddingEngine}; pub async fn create(config: &HttpModelConfig) -> Arc { - let rpm = config.rate_limit.as_ref().map_or_else( - || RateLimit::default().request_per_minute, - |rl| rl.request_per_minute, - ); + let rpm = config.rate_limit.request_per_minute; let embedding: Arc = match config.kind.as_str() { "llama.cpp/embedding" => { diff --git a/crates/tabby-common/src/config.rs b/crates/tabby-common/src/config.rs index 56acd7590ae8..4d32b4221904 100644 --- a/crates/tabby-common/src/config.rs +++ b/crates/tabby-common/src/config.rs @@ -290,7 +290,8 @@ pub struct HttpModelConfig { pub api_key: Option, #[builder(default)] - pub rate_limit: Option, + #[serde(default)] + pub rate_limit: RateLimit, /// Used by OpenAI style API for model name. #[builder(default)]