Package com.tnsai.channels.api
Record Class UnifiedChunk
java.lang.Object
java.lang.Record
com.tnsai.channels.api.UnifiedChunk
- Record Components:
conversationId- logical conversation key — same as on the parentUnifiedResponse, lets adapters fan chunks back to the right sessiondelta- text fragment to surface to the user. May be empty for control-only chunks (e.g. tool-call start) — adapters that only render text should skip blank deltas, not crash on them.done-truefor the final chunk in a reply, signalling adapters to flush / close any open visual element (typing indicator, partial-message edit, etc.). The matchingstill arrives afterward;invalid reference
UnifiedResponse#senddoneis the streaming sentinel, not the lifecycle terminator.metadata- free-form per-chunk metadata (tool-call name, provider, latency hint). Read-only — adapters must not mutate.nulltreated as empty.timestamp- when the chunk was emitted; useful for backpressure / latency telemetry. Required.
public record UnifiedChunk(String conversationId, String delta, boolean done, Map<String,Object> metadata, Instant timestamp)
extends Record
A single token / partial-response delta delivered through a streaming
channel (TNS-440). Adapters that opt into per-chunk delivery — via
StreamingChannelAdapter — receive these as the agent's
inference progresses; everyone else still gets the eventual
UnifiedResponse from ChannelAdapter.send(com.tnsai.channels.api.UnifiedResponse) when the
full reply is assembled.- Since:
- 0.10.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconversationIdrecord component.delta()Returns the value of thedeltarecord component.booleandone()Returns the value of thedonerecord component.static UnifiedChunkConvenience: terminal chunk with no further text, timestampednow.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.static UnifiedChunkConvenience: text chunk with no metadata, timestampednow.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
UnifiedChunk
public UnifiedChunk(String conversationId, String delta, boolean done, Map<String, Object> metadata, Instant timestamp) Creates an instance of aUnifiedChunkrecord class.- Parameters:
conversationId- the value for theconversationIdrecord componentdelta- the value for thedeltarecord componentdone- the value for thedonerecord componentmetadata- the value for themetadatarecord componenttimestamp- the value for thetimestamprecord component
-
-
Method Details
-
text
Convenience: text chunk with no metadata, timestampednow. -
done
Convenience: terminal chunk with no further text, timestampednow. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
conversationId
Returns the value of theconversationIdrecord component.- Returns:
- the value of the
conversationIdrecord component
-
delta
Returns the value of thedeltarecord component.- Returns:
- the value of the
deltarecord component
-
done
public boolean done()Returns the value of thedonerecord component.- Returns:
- the value of the
donerecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-