pub struct EmbeddingsBuilder<T> { /* private fields */ }Expand description
Accumulates documents and embeds their extracted texts in provider-sized batches. Text extraction occurs when documents are added; requests start when built.
Implementations§
Source§impl<T: Embed> EmbeddingsBuilder<T>
impl<T: Embed> EmbeddingsBuilder<T>
Sourcepub fn new(model: impl Into<DynModel<EmbeddingOp>>) -> Self
pub fn new(model: impl Into<DynModel<EmbeddingOp>>) -> Self
Create a new embedding builder with the given embedding model
Sourcepub fn document(self, document: T) -> Result<Self, EmbedError>
pub fn document(self, document: T) -> Result<Self, EmbedError>
Add a document to be embedded to the builder. document must implement the Embed trait.
Sourcepub fn documents(
self,
documents: impl IntoIterator<Item = T>,
) -> Result<Self, EmbedError>
pub fn documents( self, documents: impl IntoIterator<Item = T>, ) -> Result<Self, EmbedError>
Add multiple documents to be embedded to the builder. documents must be iterable
with items that implement the Embed trait.
Source§impl<T> EmbeddingsBuilder<T>where
T: Embed + WasmCompatSend,
impl<T> EmbeddingsBuilder<T>where
T: Embed + WasmCompatSend,
Sourcepub async fn build(self) -> Result<Vec<(T, Vec<Embedding>)>, ProviderError>
pub async fn build(self) -> Result<Vec<(T, Vec<Embedding>)>, ProviderError>
Generate embeddings for all documents in the builder.
Returns (document, embeddings) pairs. A document may produce one or many
embeddings depending on how its Embed implementation uses TextEmbedder.
Preserves document insertion order and each document’s text order, regardless of batch completion order. Providers must return embeddings in input order within each batch; this is not checked.
Propagates provider and transport errors. Returns an error identifying the document if it produces no text or a batch returns too few embeddings. Empty embedded collections produce no text. Surplus embeddings are ignored.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for EmbeddingsBuilder<T>
impl<T> !UnwindSafe for EmbeddingsBuilder<T>
impl<T> Freeze for EmbeddingsBuilder<T>
impl<T> Send for EmbeddingsBuilder<T>
impl<T> Sync for EmbeddingsBuilder<T>
impl<T> Unpin for EmbeddingsBuilder<T>
impl<T> UnsafeUnpin for EmbeddingsBuilder<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more