Class ContentStreamEvent
- All Implemented Interfaces:
ProgressEvent, HumanReadable, JobEvent, Serializable
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 Summary
ConstructorsConstructorDescriptionContentStreamEvent(JobSnapshot snapshot, StreamChunk chunk) Creates a content stream event from a snapshot.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.ContentStreamEvent(JobSnapshot snapshot, StreamChunk chunk, Map<String, Artifact> artifacts) Creates a content stream event with artifacts. -
Method Summary
Methods inherited from class JobProgressEvent
getPayload, getProgressPercent, hasProgress, setPayload, setProgressPercentMethods inherited from class AbstractJobEvent
message, setMessage, snapshot, timestamp
-
Constructor Details
-
ContentStreamEvent
Creates a content stream event from a snapshot.- Parameters:
snapshot- the job snapshotchunk- the stream chunk
-
ContentStreamEvent
Creates a content stream event with artifacts.- Parameters:
snapshot- the job snapshotchunk- the stream chunkartifacts- 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 snapshotchunk- the stream chunkanswer- the answer object; null on a chunk that carries noneartifacts- the artifacts the answer selected, keyed by reference; null or empty for none
-
-
Method Details
-
chunk
Gets the stream chunk. Convenience method that returns the typed payload.- Returns:
- the stream chunk
-
getArtifacts
-
getAnswer
Gets the answer object this event carries.- Returns:
- the answer, or null on a chunk that carries none
-
msgType
- Overrides:
msgTypein classJobProgressEvent<StreamChunk>
-
title
- Overrides:
titlein classJobProgressEvent<StreamChunk>
-
jobState
- Overrides:
jobStatein classJobProgressEvent<StreamChunk>
-
getHumanMessage
Description copied from interface:HumanReadableReturns a plain-text message suitable for display to end users.- Specified by:
getHumanMessagein interfaceHumanReadable- Overrides:
getHumanMessagein classJobProgressEvent<StreamChunk>- Returns:
- user-friendly message
-