Skip to main content

PromptedTextEmbedder

Struct PromptedTextEmbedder 

Source
pub struct PromptedTextEmbedder<E> { /* private fields */ }
Expand description

Wrapper that applies a PromptTemplate before calling an inner TextEmbedder.

This is the “instruction/scoped embedding” adapter when a backend:

  • ignores EmbedMode, or
  • expects explicit prompt prefixes.

Nuance: If your inner backend already applies its own prompt logic (e.g. a backend that uses EmbedMode internally), wrapping may double-prefix. Keep this opt-in.

Implementations§

Source§

impl<E> PromptedTextEmbedder<E>

Source

pub fn new(inner: E, prompt: PromptTemplate) -> Self

Source

pub fn prompt(&self) -> &PromptTemplate

Source

pub fn into_inner(self) -> E

Trait Implementations§

Source§

impl<E: Clone> Clone for PromptedTextEmbedder<E>

Source§

fn clone(&self) -> PromptedTextEmbedder<E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Debug> Debug for PromptedTextEmbedder<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: TextEmbedder> TextEmbedder for PromptedTextEmbedder<E>

Source§

fn embed_texts( &self, texts: &[String], mode: EmbedMode, ) -> Result<Vec<Vec<f32>>>

Embed texts into vectors. Read more
Source§

fn model_id(&self) -> Option<&str>

Optional: model identifier for debugging and provenance.
Source§

fn dimension(&self) -> Option<usize>

Optional: embedding dimension as returned by this embedder. Read more
Source§

fn capabilities(&self) -> TextEmbedderCapabilities

Optional: backend capability declaration. Read more
Source§

fn embed_text(&self, text: &str, mode: EmbedMode) -> Result<Vec<f32>>

Convenience: embed a single text, avoiding the &[s.to_string()][0].clone() boilerplate.

Auto Trait Implementations§

§

impl<E> Freeze for PromptedTextEmbedder<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for PromptedTextEmbedder<E>
where E: RefUnwindSafe,

§

impl<E> Send for PromptedTextEmbedder<E>
where E: Send,

§

impl<E> Sync for PromptedTextEmbedder<E>
where E: Sync,

§

impl<E> Unpin for PromptedTextEmbedder<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for PromptedTextEmbedder<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for PromptedTextEmbedder<E>
where E: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.