pub struct EmbedderPool {
document_embedder: Arc<dyn Embedder>,
semaphore: Semaphore,
max_concurrent: usize,
}Expand description
Pool of embedders with concurrency control.
Fields§
§document_embedder: Arc<dyn Embedder>Primary embedder for documents
semaphore: SemaphoreSemaphore to limit concurrent inference
max_concurrent: usizeMaximum concurrent operations
Implementations§
Source§impl EmbedderPool
impl EmbedderPool
Sourcepub fn new(embedder: Arc<dyn Embedder>, max_concurrent: usize) -> Self
pub fn new(embedder: Arc<dyn Embedder>, max_concurrent: usize) -> Self
Create a new embedder pool.
Sourcepub fn model_name(&self) -> &str
pub fn model_name(&self) -> &str
Get the model name.
Sourcepub fn modalities(&self) -> &[Modality]
pub fn modalities(&self) -> &[Modality]
Get supported modalities.
Sourcepub fn document_embedder(&self) -> Arc<dyn Embedder>
pub fn document_embedder(&self) -> Arc<dyn Embedder>
Get the underlying embedder.
Sourcepub async fn embed_batch(
&self,
texts: &[&str],
config: &EmbeddingConfig,
) -> Result<Vec<EmbeddingOutput>, EmbedError>
pub async fn embed_batch( &self, texts: &[&str], config: &EmbeddingConfig, ) -> Result<Vec<EmbeddingOutput>, EmbedError>
Embed a batch of texts.
Sourcepub async fn embed_query(
&self,
query: &str,
config: &EmbeddingConfig,
) -> Result<EmbeddingOutput, EmbedError>
pub async fn embed_query( &self, query: &str, config: &EmbeddingConfig, ) -> Result<EmbeddingOutput, EmbedError>
Embed a single query.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Get pool statistics.
Sourcepub fn max_concurrent(&self) -> usize
pub fn max_concurrent(&self) -> usize
Get max concurrent operations.
Auto Trait Implementations§
impl !Freeze for EmbedderPool
impl !RefUnwindSafe for EmbedderPool
impl Send for EmbedderPool
impl Sync for EmbedderPool
impl Unpin for EmbedderPool
impl !UnwindSafe for EmbedderPool
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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