OpenaiStreamingChatResponseSpecification

class OpenaiStreamingChatResponseSpecification(responseFlow: Flow<String>? = null, responseChunks: List<String>? = null, delayBetweenChunks: Duration = Duration.ZERO, delay: Duration = Duration.ZERO, var finishReason: String = "stop", var sendDone: Boolean = false) : AbstractStreamingResponseSpecification<ChatCompletionRequest, String, String> (source)

A specification class for defining and customizing the streaming chat response behavior in an OpenAI-like environment. This class provides configuration options for managing streaming responses, delays, chunking, and signaling the end of the response.

This class extends ResponseSpecification to offer additional parameters aimed at handling streaming chat responses.

Author

Konstantin Pavlov

Parameters

responseFlow

A flow of string-based response chunks to be emitted sequentially as part of the streaming behavior.

responseChunks

A predefined list of response content chunks to be used in the streaming response.

delayBetweenChunks

The delay duration inserted between emitting each response chunk from the flow.

delay

A global delay applied to the entire response before it is initiated.

finishReason

A descriptor to indicate the reason for completion of the response, such as "stop".

sendDone

A flag indicating whether the special marker [DONE] should be sent at the end of the streaming response.

See also

Constructors

Link copied to clipboard
constructor(responseFlow: Flow<String>? = null, responseChunks: List<String>? = null, delayBetweenChunks: Duration = Duration.ZERO, delay: Duration = Duration.ZERO, finishReason: String = "stop", sendDone: Boolean = false)

Creates an instance of OpenaiStreamingChatResponseSpecification.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Should send [DONE] at the end.

Functions

Link copied to clipboard
open override fun chunks(chunks: List<String>)
open override fun chunks(vararg chunks: String)
Link copied to clipboard
open override fun delayMillis(value: Long)
Link copied to clipboard
open override fun stream(stream: Stream<String>)