pub struct ExternalEmbedding { /* private fields */ }Expand description
External embedding provider.
This provider is used when embeddings are generated externally (e.g., by OpenAI, Cohere, or a custom service). It validates embedding dimensions but cannot generate embeddings itself.
§Usage
When using ExternalEmbedding, you must provide pre-computed embedding
vectors when recording experiences. Attempting to call embed() or
embed_batch() will return an error.
§Example
use pulsedb::embedding::{EmbeddingService, ExternalEmbedding};
// Create for OpenAI ada-002 (1536 dimensions)
let service = ExternalEmbedding::new(1536);
assert_eq!(service.dimension(), 1536);Implementations§
Source§impl ExternalEmbedding
impl ExternalEmbedding
Sourcepub fn new(dimension: usize) -> Self
pub fn new(dimension: usize) -> Self
Creates a new external embedding provider with the given dimension.
§Arguments
dimension- The expected embedding dimension
§Example
use pulsedb::embedding::ExternalEmbedding;
// all-MiniLM-L6-v2
let service = ExternalEmbedding::new(384);
// OpenAI text-embedding-3-small
let service = ExternalEmbedding::new(1536);Trait Implementations§
Source§impl Clone for ExternalEmbedding
impl Clone for ExternalEmbedding
Source§fn clone(&self) -> ExternalEmbedding
fn clone(&self) -> ExternalEmbedding
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExternalEmbedding
impl Debug for ExternalEmbedding
Source§impl EmbeddingService for ExternalEmbedding
impl EmbeddingService for ExternalEmbedding
Source§fn embed(&self, _text: &str) -> Result<Embedding>
fn embed(&self, _text: &str) -> Result<Embedding>
Generates an embedding for a single text. Read more
Source§fn embed_batch(&self, _texts: &[&str]) -> Result<Vec<Embedding>>
fn embed_batch(&self, _texts: &[&str]) -> Result<Vec<Embedding>>
Generates embeddings for multiple texts in a batch. Read more
Auto Trait Implementations§
impl Freeze for ExternalEmbedding
impl RefUnwindSafe for ExternalEmbedding
impl Send for ExternalEmbedding
impl Sync for ExternalEmbedding
impl Unpin for ExternalEmbedding
impl UnsafeUnpin for ExternalEmbedding
impl UnwindSafe for ExternalEmbedding
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more