Skip to main content

io.enterpriseai.resources.ChatStream

Source: sdks/java/enterprise-ai-java/src/main/java/io/enterpriseai/resources/ChatStream.java. Back to the Java SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Class ChatStream​

Streamed chat completion: an Iterator of chunks, a Stream or a Flow.Publisher.

Iterator<ChatChunk>, AutoCloseable

Constructor ChatStream​

ChatStream(SseStream sse)

Wraps an SSE stream of the gateway; every event becomes a ChatChunk.

NameTypeDefaultRequiredDescription
sseSseStreamyesSseStream open on the completion response.

ChatStream.close​

void close()

Closes the SSE stream and the underlying connection.

This element takes no parameter.

Returns: void.

ChatStream.collectText​

String collectText()

Concatenates every remaining delta and closes the stream.

This element takes no parameter.

Returns: String. The full text made of the remaining deltas.

ChatStream.hasNext​

boolean hasNext()

Tells whether a chunk remains; blocks until the next event.

This element takes no parameter.

Returns: boolean. True until the stream ends (data: [DONE] or end of connection).

ChatStream.next​

ChatChunk next()

Reads the next event and turns it into a ChatChunk.

This element takes no parameter.

Returns: ChatChunk. A ChatChunk: One streamed chat completion chunk.

ChatStream.publisher​

Flow.Publisher<ChatChunk> publisher(Executor executor)

Reactive view honoring back pressure.

NameTypeDefaultRequiredDescription
executorExecutoryesExecutor on which the events are read.

Returns: Flow.Publisher<ChatChunk>. A ChatChunk: One streamed chat completion chunk.

ChatStream.stream​

Stream<ChatChunk> stream()

Ordered lazy Stream of the remaining chunks; closing the Stream closes the stream.

This element takes no parameter.

Returns: Stream<ChatChunk>. A ChatChunk: One streamed chat completion chunk.