Package com.google.genkit.ai.agent
Class AgentChunk<S>
java.lang.Object
com.google.genkit.ai.agent.AgentChunk<S>
- Type Parameters:
S- the type of custom session state
AgentChunk is the ergonomic wrapper
AgentChat.sendStream(java.lang.String, java.util.function.Consumer<com.google.genkit.ai.agent.AgentChunk<S>>) hands to the per-chunk callback.
It exposes the common slices of an AgentStreamChunk: streamed model text, an artifact
update, and the post-patch custom state (the running client-side custom state with this
chunk's customPatch already applied). The raw chunk is available via raw().
-
Method Summary
Modifier and TypeMethodDescriptionartifact()Returns the artifact carried by this chunk.custom()Returns the custom state after this chunk'scustomPatchwas applied to the running client-side state.Returns the model response chunk.raw()Returns the underlying raw stream chunk.text()Returns the streamed model text for this chunk.
-
Method Details
-
text
Returns the streamed model text for this chunk.- Returns:
- the chunk text, or
nullif this chunk carried no model content
-
modelChunk
Returns the model response chunk.- Returns:
- the model chunk, or
null
-
artifact
Returns the artifact carried by this chunk.- Returns:
- the artifact, or
null
-
custom
Returns the custom state after this chunk'scustomPatchwas applied to the running client-side state.- Returns:
- the post-patch custom state, or
nullif this chunk carried no custom patch
-
raw
Returns the underlying raw stream chunk.- Returns:
- the raw chunk
-