Skip to main content

EmbeddingsBuilder

Struct EmbeddingsBuilder 

Source
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>

Source

pub fn new(model: M) -> Self

Source

pub fn document(self, doc: T) -> Result<Self, EmbedError>

Add a single document.

Source

pub fn documents( self, docs: impl IntoIterator<Item = T>, ) -> Result<Self, EmbedError>

Add multiple documents.

Source

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>
where M: Freeze, Vec<(T, Vec<String>)>: Freeze,

§

impl<M, T> RefUnwindSafe for EmbeddingsBuilder<M, T>

§

impl<M, T> Send for EmbeddingsBuilder<M, T>
where M: Send, Vec<(T, Vec<String>)>: Send,

§

impl<M, T> Sync for EmbeddingsBuilder<M, T>
where M: Sync, Vec<(T, Vec<String>)>: Sync,

§

impl<M, T> Unpin for EmbeddingsBuilder<M, T>
where M: Unpin, Vec<(T, Vec<String>)>: Unpin,

§

impl<M, T> UnsafeUnpin for EmbeddingsBuilder<M, T>
where M: UnsafeUnpin, Vec<(T, Vec<String>)>: UnsafeUnpin,

§

impl<M, T> UnwindSafe for EmbeddingsBuilder<M, T>
where M: UnwindSafe, Vec<(T, Vec<String>)>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,