fathomdb_embedder_api/
lib.rs1pub type Vector = Vec<f32>;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
4pub struct EmbedderIdentity {
5 pub name: String,
6 pub revision: String,
7 pub dimension: u32,
8}
9
10impl EmbedderIdentity {
11 #[must_use]
12 pub fn new(name: impl Into<String>, revision: impl Into<String>, dimension: u32) -> Self {
13 Self { name: name.into(), revision: revision.into(), dimension }
14 }
15}
16
17#[derive(Clone, Debug, Eq, PartialEq)]
18pub enum EmbedderError {
19 Failed { message: String },
20 Timeout,
21}
22
23pub trait Embedder: Send + Sync {
24 fn identity(&self) -> EmbedderIdentity;
25
26 fn embed(&self, input: &str) -> Result<Vector, EmbedderError>;
27}