pub struct EmbeddingProvider(/* private fields */);Expand description
Concrete embedding provider — wraps any EmbeddingBackend.
Cheap to clone (wraps Arc internally). Use as an axum service via
Service(embedder): Service<EmbeddingProvider>.
§Example
ⓘ
let client = reqwest::Client::new();
let embedder = EmbeddingProvider::new(
OpenAIEmbedding::new(client, &config)?,
);
let blob = embedder.embed("hello world").await?;Implementations§
Source§impl EmbeddingProvider
impl EmbeddingProvider
Sourcepub fn new(backend: impl EmbeddingBackend + 'static) -> Self
pub fn new(backend: impl EmbeddingBackend + 'static) -> Self
Wrap any backend. Arc is handled internally.
Sourcepub async fn embed(&self, input: &str) -> Result<Vec<u8>>
pub async fn embed(&self, input: &str) -> Result<Vec<u8>>
Embed text. Returns a little-endian f32 blob for libsql.
§Errors
Returns Error::bad_request if input is empty.
Propagates provider API errors.
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Number of dimensions this provider/model produces.
Sourcepub fn model_name(&self) -> &str
pub fn model_name(&self) -> &str
Model identifier string.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EmbeddingProvider
impl !RefUnwindSafe for EmbeddingProvider
impl Send for EmbeddingProvider
impl Sync for EmbeddingProvider
impl Unpin for EmbeddingProvider
impl UnsafeUnpin for EmbeddingProvider
impl !UnwindSafe for EmbeddingProvider
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