pub trait EmbeddingModel:
Clone
+ Sync
+ Send {
const MAX_DOCUMENTS: usize;
// Required methods
fn ndims(&self) -> usize;
fn embed_documents(
&self,
documents: impl IntoIterator<Item = String> + Send,
) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + Send;
// Provided method
fn embed_document(
&self,
document: &str,
) -> impl Future<Output = Result<Embedding, EmbeddingError>> + Send
where Self: Sync { ... }
}Expand description
Trait for embedding models that can generate embeddings for documents.
Required Associated Constants§
sourceconst MAX_DOCUMENTS: usize
const MAX_DOCUMENTS: usize
The maximum number of documents that can be embedded in a single request.
Required Methods§
sourcefn embed_documents(
&self,
documents: impl IntoIterator<Item = String> + Send,
) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + Send
fn embed_documents( &self, documents: impl IntoIterator<Item = String> + Send, ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + Send
Embed multiple documents in a single request
Provided Methods§
sourcefn embed_document(
&self,
document: &str,
) -> impl Future<Output = Result<Embedding, EmbeddingError>> + Sendwhere
Self: Sync,
fn embed_document(
&self,
document: &str,
) -> impl Future<Output = Result<Embedding, EmbeddingError>> + Sendwhere
Self: Sync,
Embed a single document
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.