Function create_completion_stream

Source
pub async fn create_completion_stream(
    client: &OpenAIClient,
    request: &CreateCompletionRequest,
) -> Result<impl Stream<Item = Result<CreateCompletionResponse, OpenAIError>>, OpenAIError>
Expand description

Creates a streaming text completion using the OpenAI Completions API.

When the stream field in the request is set to Some(true), the API will return partial responses as a stream. This function returns an asynchronous stream of CreateCompletionResponse objects. Each item in the stream represents a partial response until the final message is received (typically signaled by [DONE]).