pub struct EmbeddingService { /* private fields */ }Expand description
Embedding service for generating vector representations.
Implementations§
Source§impl EmbeddingService
impl EmbeddingService
Sourcepub fn with_model(model_name: String, dimension: usize) -> Self
pub fn with_model(model_name: String, dimension: usize) -> Self
Create with custom model.
Sourcepub fn model_name(&self) -> &str
pub fn model_name(&self) -> &str
Get the model name.
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Returns whether semantic embeddings are currently available.
Sourcepub fn disabled_reason(&self) -> Option<&str>
pub fn disabled_reason(&self) -> Option<&str>
Returns disabled reason if embeddings are unavailable.
Sourcepub async fn embed(&self, text: &str) -> MemoryResult<Vec<f32>>
pub async fn embed(&self, text: &str) -> MemoryResult<Vec<f32>>
Generate embeddings for a single text.
Sourcepub async fn embed_batch(&self, texts: &[String]) -> MemoryResult<Vec<Vec<f32>>>
pub async fn embed_batch(&self, texts: &[String]) -> MemoryResult<Vec<Vec<f32>>>
Generate embeddings for multiple texts.
Sourcepub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
Calculate cosine similarity between two vectors.
Sourcepub fn euclidean_distance(a: &[f32], b: &[f32]) -> f32
pub fn euclidean_distance(a: &[f32], b: &[f32]) -> f32
Calculate Euclidean distance between two vectors.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EmbeddingService
impl !RefUnwindSafe for EmbeddingService
impl Send for EmbeddingService
impl Sync for EmbeddingService
impl Unpin for EmbeddingService
impl UnsafeUnpin for EmbeddingService
impl !UnwindSafe for EmbeddingService
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
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().