pub struct OpenAIEmbedding { /* private fields */ }Expand description
OpenAI embedding provider with production features.
Implementations§
Source§impl OpenAIEmbedding
impl OpenAIEmbedding
Sourcepub fn new(api_key: impl Into<String>, model: Option<String>) -> Self
pub fn new(api_key: impl Into<String>, model: Option<String>) -> Self
Create a new OpenAI embedding provider.
Sourcepub fn with_config(api_key: impl Into<String>, config: OpenAIConfig) -> Self
pub fn with_config(api_key: impl Into<String>, config: OpenAIConfig) -> Self
Create with custom configuration.
Sourcepub fn with_dimensions(self, dimensions: usize) -> Self
pub fn with_dimensions(self, dimensions: usize) -> Self
Set custom dimensions (for text-embedding-3-* models).
Sourcepub fn stats(&self) -> UsageSnapshot
pub fn stats(&self) -> UsageSnapshot
Get usage statistics.
Trait Implementations§
Source§impl EmbeddingProvider for OpenAIEmbedding
impl EmbeddingProvider for OpenAIEmbedding
Source§fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generate embedding for text.
Source§fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Generate embeddings for multiple texts in batch.
Source§fn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Get embedding dimensions.
Auto Trait Implementations§
impl Freeze for OpenAIEmbedding
impl !RefUnwindSafe for OpenAIEmbedding
impl Send for OpenAIEmbedding
impl Sync for OpenAIEmbedding
impl Unpin for OpenAIEmbedding
impl UnsafeUnpin for OpenAIEmbedding
impl !UnwindSafe for OpenAIEmbedding
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request