pub struct OAIEmbedding { /* private fields */ }Expand description
Client for making embedding requests to OpenAI-compatible APIs.
This client handles authentication and communication with embedding services that implement the OpenAI embeddings API format.
Implementations§
Source§impl OAIEmbedding
impl OAIEmbedding
Sourcepub fn new(
base_url: String,
api_key: Option<SecretString>,
model: String,
) -> Self
pub fn new( base_url: String, api_key: Option<SecretString>, model: String, ) -> Self
Creates a new OpenAI-compatible embedding implementation.
§Arguments
base_url- The base URL of the embeddings API endpointapi_key- Optional API key for authenticationmodel- Name of the embedding model to use
Trait Implementations§
Source§impl Debug for OAIEmbedding
impl Debug for OAIEmbedding
Source§impl EmbeddingInterface for OAIEmbedding
impl EmbeddingInterface for OAIEmbedding
Source§fn embed_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'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_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generates embedding vectors for a batch of text inputs.
This method sends a single request to the embeddings API to generate embeddings for multiple input strings at once.
§Arguments
inputs- A slice of text strings to embed. If empty, an empty vector is returned without making an API call.
§Returns
A vector of embedding vectors (Vec<Vec<f32>>), where each inner
vector corresponds to the embedding of the input at the same index.
§Errors
Returns an error if building the request fails, the API request fails, or if the response cannot be processed.
Auto Trait Implementations§
impl Freeze for OAIEmbedding
impl !RefUnwindSafe for OAIEmbedding
impl Send for OAIEmbedding
impl Sync for OAIEmbedding
impl Unpin for OAIEmbedding
impl !UnwindSafe for OAIEmbedding
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> 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 moreSource§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