pub struct OpenAIProvider { /* private fields */ }Expand description
OpenAI embedding provider configuration.
Implementations§
Source§impl OpenAIProvider
impl OpenAIProvider
Sourcepub fn new(api_key: impl Into<String>) -> Result<Self>
pub fn new(api_key: impl Into<String>) -> Result<Self>
Create a new OpenAI provider with the given API key.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create a provider from the OPENAI_API_KEY environment variable.
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set the model to use for embeddings.
Sourcepub async fn request_async(&self, texts: &[&str]) -> Result<Vec<Embedding>>
pub async fn request_async(&self, texts: &[&str]) -> Result<Vec<Embedding>>
Make an HTTP request to the OpenAI API with retry logic (async version). Safe to call from within an async runtime.
Sourcepub async fn embed_async(&self, text: &str) -> Result<Embedding>
pub async fn embed_async(&self, text: &str) -> Result<Embedding>
Async version of embed for use in async contexts (e.g., MCP server).
Trait Implementations§
Source§impl EmbeddingProvider for OpenAIProvider
impl EmbeddingProvider for OpenAIProvider
Auto Trait Implementations§
impl !RefUnwindSafe for OpenAIProvider
impl !UnwindSafe for OpenAIProvider
impl Freeze for OpenAIProvider
impl Send for OpenAIProvider
impl Sync for OpenAIProvider
impl Unpin for OpenAIProvider
impl UnsafeUnpin 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> 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