pub trait EmbeddingModel: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn dimensions(&self) -> usize;
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
input: EmbedInput,
settings: &'life1 EmbeddingSettings,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided methods
fn max_tokens(&self) -> usize { ... }
fn embed_query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn embed_documents<'life0, 'async_trait>(
&'life0 self,
docs: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64, EmbeddingError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
}Available on crate feature
embeddings only.Expand description
Core trait for embedding models.
Required Methods§
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Get the default embedding dimensions.
Sourcefn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
input: EmbedInput,
settings: &'life1 EmbeddingSettings,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
input: EmbedInput,
settings: &'life1 EmbeddingSettings,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Generate embeddings.
Provided Methods§
Sourcefn max_tokens(&self) -> usize
fn max_tokens(&self) -> usize
Get the maximum tokens per input.
Sourcefn embed_query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn embed_query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Embed a single query.
Sourcefn embed_documents<'life0, 'async_trait>(
&'life0 self,
docs: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn embed_documents<'life0, 'async_trait>(
&'life0 self,
docs: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Embed multiple documents.
Sourcefn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64, EmbeddingError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Count tokens in text (if supported).