Interface NaruStreamChunk
- All Known Implementing Classes:
NaruStreamChunkData
This is the only shape the actor loop, the session writer and the renderers are allowed to see. Providers hand over wildly different payloads -- a dedicated reasoning field, an SSE frame, a JSON line, a whole finished body -- and all of it is normalised to this before anything downstream runs, so a renderer never has to know which provider it is displaying.
A chunk is a fragment, not a message. A streamed answer arrives as many
ANSWER chunks that concatenate to the answer, and a single response may
interleave THINKING and ANSWER freely. Anything that needs the whole thing
must accumulate; see index() for the order to accumulate in.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancomplete()Whether NARU knows this chunk is final, meaning no further content of the same segment can still arrive.How thinking content was recovered, meaningful only forNaruChunkKind.THINKINGchunks;nullotherwise.intindex()Position of this chunk in its response, counting from zero and increasing by one per emitted chunk.kind()What this content is.provider()Provider that produced this chunk, for provenance.text()The content, which may be empty but is nevernull.
-
Method Details
-
kind
NaruChunkKind kind()What this content is. -
text
String text()The content, which may be empty but is nevernull. ForNaruChunkKind.TOOL_CALLthis is the call's rendered form rather than a structured payload; structured tool calls remain onNaruResponse. -
index
int index()Position of this chunk in its response, counting from zero and increasing by one per emitted chunk. Order is what lets a consumer reassemble, so it is assigned at emission rather than derived later. -
provider
String provider()Provider that produced this chunk, for provenance. May benullfor a chunk synthesised by NARU itself rather than by a model. -
extraction
NaruThinkingExtraction extraction()How thinking content was recovered, meaningful only forNaruChunkKind.THINKINGchunks;nullotherwise. -
complete
boolean complete()Whether NARU knows this chunk is final, meaning no further content of the same segment can still arrive.This is deliberately conservative, because a streaming reader emits before it knows what comes next. Text that precedes a delimiter this parser has already seen is final; text emitted speculatively mid-stream is not, and neither is text from a reasoning block that never closed.
The consequence worth knowing: a streamed response reports
falseon its trailing chunks, and a non-streamed one reportstruethroughout, because in the batch case the whole body is known before anything is emitted. Callers that need to know whether generation actually finished should ask the source of truth for the whole stream rather than reading this off the last chunk -- seeNaruThinkingTagParser.isSegmentComplete().
-