1
2
3
4
5
6
7
8
9
10
11
12
13
//! Defines the interface for an embedding model that can embed text input.
use async_trait::async_trait;

use crate::error::AnchorChainError;

/// Defines the interface for an embedding model that can embed text input.
#[async_trait]
pub trait EmbeddingModel {
    /// Embeds the given input text and returns the resulting vector.
    async fn embed(&self, input: String) -> Result<Vec<f32>, AnchorChainError>;

    fn dimensions(&self) -> usize;
}