blazen_embed_fastembed/options.rs
1//! Configuration options for the fastembed local embedding backend.
2
3use serde::{Deserialize, Serialize};
4use std::path::PathBuf;
5
6/// Options for constructing a [`FastEmbedModel`](crate::FastEmbedModel).
7///
8/// All fields are optional; defaults produce a working model using
9/// `BAAI/bge-small-en-v1.5` on CPU with fastembed's built-in cache.
10#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11pub struct FastEmbedOptions {
12 /// Fastembed model variant name (e.g. `"BGESmallENV15"`).
13 ///
14 /// Parsed via `fastembed::EmbeddingModel::from_str`. When `None`, defaults
15 /// to `fastembed::EmbeddingModel::BGESmallENV15`.
16 pub model_name: Option<String>,
17 /// Model cache directory. When `None`, fastembed uses its built-in cache
18 /// (controlled by `FASTEMBED_CACHE_DIR` / `HF_HOME` env vars).
19 pub cache_dir: Option<PathBuf>,
20 /// Maximum batch size for embedding. When `None`, fastembed uses its
21 /// default (256).
22 pub max_batch_size: Option<usize>,
23 /// Whether to display download progress when fetching models from
24 /// `HuggingFace`. Defaults to `true`.
25 pub show_download_progress: Option<bool>,
26}
27
28#[cfg(test)]
29mod tests {
30 use super::*;
31
32 #[test]
33 fn default_options_fields_are_none() {
34 let opts = FastEmbedOptions::default();
35 assert!(opts.model_name.is_none());
36 assert!(opts.cache_dir.is_none());
37 assert!(opts.max_batch_size.is_none());
38 assert!(opts.show_download_progress.is_none());
39 }
40}