Class ContentStreamEvent

All Implemented Interfaces:
ProgressEvent, HumanReadable, JobEvent, Serializable

public class ContentStreamEvent extends JobProgressEvent<StreamChunk>
Event for streaming LLM content chunks to users.

Provides real-time delivery of generated content with automatic lifecycle phase mapping: middle chunks use MsgType.PROGRESSING under the title Streaming Content, the final chunk uses MsgType.COMPLETING under Streaming Complete and is 100%. The human message is the chunk's content, else Streaming... or, on the last chunk, Stream completed. The log message is Streaming chunk: <first fifty characters>, or Streaming complete on the last chunk.

JSON Structure: the progress event's fields plus a chunk object containing content text, token count, and completion flag, and artifacts on any chunk given some; the artifacts are copied at construction and read as null when none were given. An event that carries an answer also has answer, the object the model filled, and its artifacts are then the ones that answer selected, keyed by reference.

Since:
0.1 (2025-10-11)
Author:
Andrey Santrosyan
See Also:
  • Constructor Details

    • ContentStreamEvent

      public ContentStreamEvent(JobSnapshot snapshot, StreamChunk chunk)
      Creates a content stream event from a snapshot.
      Parameters:
      snapshot - the job snapshot
      chunk - the stream chunk
    • ContentStreamEvent

      public ContentStreamEvent(JobSnapshot snapshot, StreamChunk chunk, Map<String,Artifact> artifacts)
      Creates a content stream event with artifacts.
      Parameters:
      snapshot - the job snapshot
      chunk - the stream chunk
      artifacts - artifacts to include, on any chunk; null or empty for none
    • ContentStreamEvent

      public ContentStreamEvent(JobSnapshot snapshot, StreamChunk chunk, ArtifactResponse<?> answer, Map<String,Artifact> artifacts)
      Creates the event that carries an answer: the object the model filled, beside the chunk holding its text, and the artifacts the answer selected.
      Parameters:
      snapshot - the job snapshot
      chunk - the stream chunk
      answer - the answer object; null on a chunk that carries none
      artifacts - the artifacts the answer selected, keyed by reference; null or empty for none
  • Method Details