pub trait EmbeddingModel: WasmCompatSend + WasmCompatSync {
type Client;
const MAX_DOCUMENTS: usize;
// Required methods
fn make(
client: &Self::Client,
model: impl Into<String>,
dims: Option<usize>,
) -> Self;
fn ndims(&self) -> usize;
fn embed_texts(
&self,
texts: impl IntoIterator<Item = String> + WasmCompatSend,
) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + WasmCompatSend;
// Provided method
fn embed_text(
&self,
text: &str,
) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend { ... }
}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 Associated Types§
Required Methods§
Sourcefn make(
client: &Self::Client,
model: impl Into<String>,
dims: Option<usize>,
) -> Self
fn make( client: &Self::Client, model: impl Into<String>, dims: Option<usize>, ) -> Self
Construct a model handle from a provider client, model identifier, and optional dimensions.
Sourcefn embed_texts(
&self,
texts: impl IntoIterator<Item = String> + WasmCompatSend,
) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + WasmCompatSend
fn embed_texts( &self, texts: impl IntoIterator<Item = String> + WasmCompatSend, ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + WasmCompatSend
Embed multiple text documents in a single request
Provided Methods§
Sourcefn embed_text(
&self,
text: &str,
) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend
fn embed_text( &self, text: &str, ) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend
Embed a single text 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.
Implementors§
Source§impl EmbeddingModel for MockEmbeddingModel
Available on crate feature test-utils only.
impl EmbeddingModel for MockEmbeddingModel
Available on crate feature
test-utils only.