use crate::embedding_generator::EmbeddingGenerator;
use crate::model_type::EmbeddingModelType;
use crate::hanzo_embedding_errors::HanzoEmbeddingError;
use async_trait::async_trait;

#[derive(Clone)]
pub struct MockGenerator {
    model_type: EmbeddingModelType,
    num_embeddings: usize,
}

impl MockGenerator {
    pub fn new(model_type: EmbeddingModelType, num_embeddings: usize) -> Self {
        MockGenerator {
            model_type,
            num_embeddings,
        }
    }
}

#[async_trait]
impl EmbeddingGenerator for MockGenerator {
    fn model_type(&self) -> EmbeddingModelType {
        self.model_type.clone()
    }

    fn set_model_type(&mut self, model_type: EmbeddingModelType) {
        self.model_type = model_type;
    }

    fn box_clone(&self) -> Box<dyn EmbeddingGenerator> {
        Box::new((*self).clone())
    }

    async fn generate_embedding(&self, _input_string: &str) -> Result<Vec<f32>, HanzoEmbeddingError> {
        Ok(vec![0.0; self.num_embeddings])
    }

    async fn generate_embeddings(&self, input_strings: &Vec<String>) -> Result<Vec<Vec<f32>>, HanzoEmbeddingError> {
        Ok(input_strings.iter().map(|_| vec![0.0; self.num_embeddings]).collect())
    }
}
