Package net.thevpc.naru.api.model
Class NaruThinkingSegment
java.lang.Object
net.thevpc.naru.api.model.NaruThinkingSegment
- All Implemented Interfaces:
Cloneable,NToElement,NCopiable
One continuous stretch of model reasoning, kept separate from the visible
answer on
NaruMessage.
Segmented rather than one blob because reasoning is rarely contiguous: a model may think, answer, think again, and answer again. Collapsing that into a single string loses the order, so a transcript cannot show how the answer was arrived at, and a truncated session cannot tell which thought was cut short.
Immutable. Built incrementally by the stream pipeline and sealed once the segment is known to be finished.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longSentinel for "the provider did not report this", distinct from a genuine zero. -
Constructor Summary
ConstructorsConstructorDescriptionNaruThinkingSegment(int index, String text, NaruThinkingExtraction extraction, String provider) NaruThinkingSegment(int index, String text, NaruThinkingExtraction extraction, String provider, long thinkingTokens, boolean complete) NaruThinkingSegment(NElement other) -
Method Summary
Modifier and TypeMethodDescriptionprotected NaruThinkingSegmentclone()copy()intgetIndex()getText()longbooleanWhether the token count is a real measurement rather than a stand-in.booleanstatic NaruThinkingSegmentlongThe token count, or 0 when unknown.toString()Concatenation of this segment's reasoning, for the legacyNaruMessage.getThinking()string field.
-
Field Details
-
UNKNOWN_TOKENS
public static final long UNKNOWN_TOKENSSentinel for "the provider did not report this", distinct from a genuine zero. Matches the convention already used for cache accounting.- See Also:
-
-
Constructor Details
-
NaruThinkingSegment
public NaruThinkingSegment(int index, String text, NaruThinkingExtraction extraction, String provider, long thinkingTokens, boolean complete) -
NaruThinkingSegment
public NaruThinkingSegment(int index, String text, NaruThinkingExtraction extraction, String provider) -
NaruThinkingSegment
-
-
Method Details
-
of
-
toElement
- Specified by:
toElementin interfaceNToElement
-
hasTokenCount
public boolean hasTokenCount()Whether the token count is a real measurement rather than a stand-in. -
tokenCountOrZero
public long tokenCountOrZero()The token count, or 0 when unknown.Returns 0 rather than the sentinel for arithmetic, so summing segments cannot accidentally bill a negative number. Use
hasTokenCount()when the difference between "none" and "not measured" matters. -
copy
-
clone
-
getIndex
public int getIndex() -
getText
-
getExtraction
-
getProvider
-
getThinkingTokens
public long getThinkingTokens() -
isComplete
public boolean isComplete() -
toString
Concatenation of this segment's reasoning, for the legacyNaruMessage.getThinking()string field.
-