Struct async_openai::Chat
source · pub struct Chat<'c> { /* private fields */ }
Expand description
Given a chat conversation, the model will return a chat completion response.
Implementations§
source§impl<'c> Chat<'c>
impl<'c> Chat<'c>
pub fn new(client: &'c Client) -> Self
sourcepub async fn create(
&self,
request: CreateChatCompletionRequest
) -> Result<CreateChatCompletionResponse, OpenAIError>
pub async fn create( &self, request: CreateChatCompletionRequest ) -> Result<CreateChatCompletionResponse, OpenAIError>
Creates a completion for the chat message
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.