pub struct Chat<'c, C: Config> { /* private fields */ }
Expand description
Given a list of messages comprising a conversation, the model will return a response.
Related guide: Chat completions
Implementations§
Source§impl<'c, C: Config> Chat<'c, C>
impl<'c, C: Config> Chat<'c, C>
pub fn new(client: &'c Client<C>) -> Self
Sourcepub async fn create(
&self,
request: CreateChatCompletionRequest,
) -> Result<CreateChatCompletionResponse, OpenAIError>
pub async fn create( &self, request: CreateChatCompletionRequest, ) -> Result<CreateChatCompletionResponse, OpenAIError>
Creates a model response for the given chat conversation.
Sourcepub async fn create_stream(
&self,
request: CreateChatCompletionRequest,
) -> Result<ChatCompletionResponseStream, OpenAIError>
pub async fn create_stream( &self, request: CreateChatCompletionRequest, ) -> Result<ChatCompletionResponseStream, OpenAIError>
Creates a completion for the chat message
partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE]
message.
ChatCompletionResponseStream is a parsed SSE stream until a [DONE] is received from server.
Auto Trait Implementations§
impl<'c, C> Freeze for Chat<'c, C>
impl<'c, C> !RefUnwindSafe for Chat<'c, C>
impl<'c, C> Send for Chat<'c, C>where
C: Sync,
impl<'c, C> Sync for Chat<'c, C>where
C: Sync,
impl<'c, C> Unpin for Chat<'c, C>
impl<'c, C> !UnwindSafe for Chat<'c, C>
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