pub struct EmbeddingsBuilder<M, T> { /* private fields */ }Expand description
Accumulates documents, embeds them in efficient batches, and returns each document paired with its embedding(s).
Implementations§
Source§impl<M: EmbeddingModel, T: Embed> EmbeddingsBuilder<M, T>
impl<M: EmbeddingModel, T: Embed> EmbeddingsBuilder<M, T>
pub fn new(model: M) -> Self
Sourcepub fn document(self, doc: T) -> Result<Self, EmbedError>
pub fn document(self, doc: T) -> Result<Self, EmbedError>
Add a single document.
Sourcepub fn documents(
self,
docs: impl IntoIterator<Item = T>,
) -> Result<Self, EmbedError>
pub fn documents( self, docs: impl IntoIterator<Item = T>, ) -> Result<Self, EmbedError>
Add multiple documents.
Sourcepub async fn build(self) -> Result<Vec<(T, Vec<Embedding>)>, EmbeddingError>
pub async fn build(self) -> Result<Vec<(T, Vec<Embedding>)>, EmbeddingError>
Embed all queued documents.
Returns Vec<(T, Vec<Embedding>)>. Each Vec<Embedding> has one entry
per text the document pushed via Embed::embed — same order.
Auto Trait Implementations§
impl<M, T> Freeze for EmbeddingsBuilder<M, T>
impl<M, T> RefUnwindSafe for EmbeddingsBuilder<M, T>
impl<M, T> Send for EmbeddingsBuilder<M, T>
impl<M, T> Sync for EmbeddingsBuilder<M, T>
impl<M, T> Unpin for EmbeddingsBuilder<M, T>
impl<M, T> UnsafeUnpin for EmbeddingsBuilder<M, T>
impl<M, T> UnwindSafe for EmbeddingsBuilder<M, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more