pub struct OpenAIProvider {
model: String,
dims: usize,
}Expand description
Embedding provider using the OpenAI API.
Calls the POST /v1/embeddings endpoint with the configured model.
Requires the OPENAI_API_KEY environment variable to be set.
§Features
- Batched embedding (multiple texts per API call)
- Exponential backoff retry for rate limits and server errors
- Configurable timeout and max retries
Fields§
§model: StringModel name (e.g. "text-embedding-3-small").
dims: usizeVector dimensionality (e.g. 1536).
Implementations§
Source§impl OpenAIProvider
impl OpenAIProvider
Sourcepub fn new(config: &EmbeddingConfig) -> Result<Self>
pub fn new(config: &EmbeddingConfig) -> Result<Self>
Create a new OpenAI provider from configuration.
§Errors
Returns an error if model or dims is not set in config,
or if OPENAI_API_KEY is not in the environment.
Trait Implementations§
Source§impl EmbeddingProvider for OpenAIProvider
impl EmbeddingProvider for OpenAIProvider
Auto Trait Implementations§
impl Freeze for OpenAIProvider
impl RefUnwindSafe for OpenAIProvider
impl Send for OpenAIProvider
impl Sync for OpenAIProvider
impl Unpin for OpenAIProvider
impl UnwindSafe for OpenAIProvider
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