Package net.thevpc.naru.api.model
Record Class NaruStreamChunkData
java.lang.Object
java.lang.Record
net.thevpc.naru.api.model.NaruStreamChunkData
- All Implemented Interfaces:
NaruStreamChunk
public record NaruStreamChunkData(NaruChunkKind kind, String text, int index, String provider, NaruThinkingExtraction extraction, boolean complete)
extends Record
implements NaruStreamChunk
The one
NaruStreamChunk implementation.
Immutability is not incidental. A streaming reader hands chunks to a renderer on a transport thread while the model call accumulates the same chunks on a worker thread, so a mutable chunk could be seen half-updated by both.
-
Constructor Summary
ConstructorsConstructorDescriptionNaruStreamChunkData(NaruChunkKind kind, String text, int index, String provider, NaruThinkingExtraction extraction, boolean complete) Creates an instance of aNaruStreamChunkDatarecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic NaruStreamChunkDataasComplete(boolean newComplete) booleancomplete()Returns the value of thecompleterecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theextractionrecord component.final inthashCode()Returns a hash code value for this object.intindex()Returns the value of theindexrecord component.kind()Returns the value of thekindrecord component.logMode()The log mode this chunk should be rendered under, which is how a renderer that carries no styling of its own -- a browser, an HTTP client -- can still tell thinking from answer.static NaruStreamChunkDataof(NaruChunkKind kind, String text, int index) static NaruStreamChunkDataof(NaruChunkKind kind, String text, int index, String provider) provider()Returns the value of theproviderrecord component.text()Returns the value of thetextrecord component.static NaruStreamChunkDatathinking(String text, int index, String provider, NaruThinkingExtraction extraction, boolean complete) toString()Returns a string representation of this record class.withIndex(int newIndex)
-
Constructor Details
-
NaruStreamChunkData
public NaruStreamChunkData(NaruChunkKind kind, String text, int index, String provider, NaruThinkingExtraction extraction, boolean complete) Creates an instance of aNaruStreamChunkDatarecord class.- Parameters:
kind- the value for thekindrecord componenttext- the value for thetextrecord componentindex- the value for theindexrecord componentprovider- the value for theproviderrecord componentextraction- the value for theextractionrecord componentcomplete- the value for thecompleterecord component
-
-
Method Details
-
of
-
of
-
thinking
public static NaruStreamChunkData thinking(String text, int index, String provider, NaruThinkingExtraction extraction, boolean complete) -
answer
-
withText
-
withIndex
-
asComplete
-
providerOptional
-
extractionOptional
-
logMode
The log mode this chunk should be rendered under, which is how a renderer that carries no styling of its own -- a browser, an HTTP client -- can still tell thinking from answer. -
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 '=='. -
kind
Returns the value of thekindrecord component.- Specified by:
kindin interfaceNaruStreamChunk- Returns:
- the value of the
kindrecord component
-
text
Returns the value of thetextrecord component.- Specified by:
textin interfaceNaruStreamChunk- Returns:
- the value of the
textrecord component
-
index
public int index()Returns the value of theindexrecord component.- Specified by:
indexin interfaceNaruStreamChunk- Returns:
- the value of the
indexrecord component
-
provider
Returns the value of theproviderrecord component.- Specified by:
providerin interfaceNaruStreamChunk- Returns:
- the value of the
providerrecord component
-
extraction
Returns the value of theextractionrecord component.- Specified by:
extractionin interfaceNaruStreamChunk- Returns:
- the value of the
extractionrecord component
-
complete
public boolean complete()Returns the value of thecompleterecord component.- Specified by:
completein interfaceNaruStreamChunk- Returns:
- the value of the
completerecord component
-