Class StreamingResponseAggregator
java.lang.Object
com.google.adk.models.springai.StreamingResponseAggregator
Aggregates streaming responses from Spring AI models.
This class helps manage the accumulation of partial responses in streaming mode, ensuring that text content is properly concatenated and tool calls are correctly handled.
Thread Safety: This class is thread-safe. All public methods are synchronized to ensure safe concurrent access. The internal state is protected using a combination of thread-safe data structures and synchronization locks.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the current accumulated text length.Returns the final aggregated response and resets the aggregator.booleanisEmpty()Returns true if no content has been processed yet.processStreamingResponse(LlmResponse response) Processes a streaming LlmResponse and returns the current aggregated state.voidreset()Resets the aggregator for reuse.
-
Constructor Details
-
StreamingResponseAggregator
public StreamingResponseAggregator()
-
-
Method Details
-
processStreamingResponse
Processes a streaming LlmResponse and returns the current aggregated state.- Parameters:
response- The streaming response to process- Returns:
- The current aggregated LlmResponse
-
getFinalResponse
Returns the final aggregated response and resets the aggregator.- Returns:
- The final complete response
-
reset
public void reset()Resets the aggregator for reuse. -
isEmpty
public boolean isEmpty()Returns true if no content has been processed yet. -
getAccumulatedTextLength
public int getAccumulatedTextLength()Returns the current accumulated text length.
-