pub struct OpenAiEmbeddingProvider { /* private fields */ }Expand description
Embedding provider backed by the OpenAI embeddings API.
Stores the API key, model, and dimension configuration. Calling [embed()]
performs a real HTTP request when the http-embeddings feature is enabled.
Without the feature, it returns an error. For local/offline embeddings, use
LocalEmbedding.
Implementations§
Source§impl OpenAiEmbeddingProvider
impl OpenAiEmbeddingProvider
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.
model defaults to "text-embedding-3-small" when None.
Sourcepub fn with_base_url(
api_key: impl Into<String>,
model: Option<String>,
base_url: impl Into<String>,
) -> Self
pub fn with_base_url( api_key: impl Into<String>, model: Option<String>, base_url: impl Into<String>, ) -> Self
Create with a custom base URL (e.g. Azure OpenAI endpoint).
Sourcepub fn with_dimensions(self, dimensions: usize) -> Self
pub fn with_dimensions(self, dimensions: usize) -> Self
Override the output dimension count.
Trait Implementations§
Source§impl EmbeddingProvider for OpenAiEmbeddingProvider
impl EmbeddingProvider for OpenAiEmbeddingProvider
Source§fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = ArgentorResult<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 = ArgentorResult<Vec<f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Compute embedding vector for a single text.
Source§fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = ArgentorResult<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 = ArgentorResult<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Compute embeddings for a batch of texts.
Auto Trait Implementations§
impl Freeze for OpenAiEmbeddingProvider
impl RefUnwindSafe for OpenAiEmbeddingProvider
impl Send for OpenAiEmbeddingProvider
impl Sync for OpenAiEmbeddingProvider
impl Unpin for OpenAiEmbeddingProvider
impl UnsafeUnpin for OpenAiEmbeddingProvider
impl UnwindSafe for OpenAiEmbeddingProvider
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