pub struct OpenAIChatCompletionClient { /* private fields */ }Expand description
An OpenAI (or OpenAI-compatible) chat client.
Implementations§
Source§impl OpenAIChatCompletionClient
impl OpenAIChatCompletionClient
Sourcepub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
Create a client for the given API key and default model.
Sourcepub fn from_env(model: impl Into<String>) -> Result<Self>
pub fn from_env(model: impl Into<String>) -> Result<Self>
Build a client from the OPENAI_API_KEY (and optional
OPENAI_BASE_URL) environment variables.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the base URL (for Azure OpenAI or compatible servers).
Sourcepub fn with_organization(self, org: impl Into<String>) -> Self
pub fn with_organization(self, org: impl Into<String>) -> Self
Set the organization header.
Trait Implementations§
Source§impl ChatClient for OpenAIChatCompletionClient
impl ChatClient for OpenAIChatCompletionClient
Source§fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a complete (non-streaming) response.
Source§fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a streaming response as a sequence of updates.
Source§impl Clone for OpenAIChatCompletionClient
impl Clone for OpenAIChatCompletionClient
Source§fn clone(&self) -> OpenAIChatCompletionClient
fn clone(&self) -> OpenAIChatCompletionClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for OpenAIChatCompletionClient
impl !UnwindSafe for OpenAIChatCompletionClient
impl Freeze for OpenAIChatCompletionClient
impl Send for OpenAIChatCompletionClient
impl Sync for OpenAIChatCompletionClient
impl Unpin for OpenAIChatCompletionClient
impl UnsafeUnpin for OpenAIChatCompletionClient
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