crabmate 0.5.0

Rust AI agent: OpenAI-compatible chat/completions, function calling, HTTP serve, ops CLI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! fastembed 初始化:缓存目录统一为 [`crate::cm_config::ensure_fastembed_cache_dir`]。

#[cfg(feature = "fastembed")]
use fastembed::{EmbeddingModel, TextEmbedding, TextInitOptions};

/// 使用 XDG Cache 下的 `fastembed/` 子目录初始化嵌入模型。
#[cfg(feature = "fastembed")]
pub fn try_new_text_embedding() -> Result<TextEmbedding, String> {
    let cache = crate::cm_config::ensure_fastembed_cache_dir()?;
    TextEmbedding::try_new(
        TextInitOptions::new(EmbeddingModel::AllMiniLML6V2).with_cache_dir(cache),
    )
    .map_err(|e| format!("fastembed 初始化失败: {e}"))
}