use anyhow::Result;
use candle_core::Device;
use hf_hub::api::tokio::Api;
use super::{download, model::Qwen3EmbeddingModel, validation};
use crate::types::{CachePath, ModelName};
pub struct HuggingFaceBackend {
device: Device,
api: Api,
}
impl HuggingFaceBackend {
pub fn new() -> Result<Self> {
let device = Device::Cpu;
let api = Api::new()?;
Ok(Self { device, api })
}
pub async fn load_qwen3_model(
&self,
model_name: &ModelName,
cache_dir: &CachePath,
) -> Result<Qwen3EmbeddingModel> {
validation::validate_model_inputs(model_name, cache_dir)?;
download::load_qwen3_model(&self.api, &self.device, model_name, cache_dir).await
}
}