pub struct OpenAIProvider(/* private fields */);Expand description
OpenAI provider (also works with any OpenAI-compatible API).
Implementations§
Source§impl OpenAIProvider
impl OpenAIProvider
Sourcepub fn new(config: ProviderConfig) -> Self
pub fn new(config: ProviderConfig) -> Self
Create a new OpenAI provider. Uses the default api.openai.com base
URL unless overridden via config.base_url.
Trait Implementations§
Source§impl Provider for OpenAIProvider
impl Provider for OpenAIProvider
Source§fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a chat completion request and get the full response.
Source§fn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<StreamChunk>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<StreamChunk>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a streaming chat completion request.
Source§fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 EmbeddingRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 EmbeddingRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbeddingResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generate embeddings for one or more input strings. Read more
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