Skip to content

Commit

Permalink
chore: use serde default for rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
zwpaper committed Nov 25, 2024
1 parent 76ca9d6 commit 3d90296
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 2 additions & 5 deletions crates/http-api-bindings/src/embedding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Embedding> {
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<dyn Embedding> = match config.kind.as_str() {
"llama.cpp/embedding" => {
Expand Down
3 changes: 2 additions & 1 deletion crates/tabby-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ pub struct HttpModelConfig {
pub api_key: Option<String>,

#[builder(default)]
pub rate_limit: Option<RateLimit>,
#[serde(default)]
pub rate_limit: RateLimit,

/// Used by OpenAI style API for model name.
#[builder(default)]
Expand Down

0 comments on commit 3d90296

Please sign in to comment.