类:StreamingResponseAggregator
java.lang.Object
com.google.adk.models.springai.StreamingResponseAggregator
汇总来自 Spring AI 模型的流式响应数据。
这个类有助于在流式传输模式下管理部分响应的累积过程,确保文本内容能够被正确地拼接在一起,并且工具调用也能得到妥善处理。
线程安全性(Thread Safety): 这个类是线程安全的。所有的公共方法都经过了同步处理,以确保在多线程环境下能够安全地并发访问。类的内部状态通过使用线程安全的数据结构以及同步锁来加以保护。
-
构造函数概述
Constructors -
方法概述
Modifier and TypeMethodDescriptionint返回当前累积的文本长度。返回最终的聚合响应结果,并重置聚合器(aggregator)。booleanisEmpty()如果尚未处理任何内容,则返回 `true`。processStreamingResponse(LlmResponse response) 处理流式 LLMResponse 数据,并返回当前的聚合状态。voidreset()将聚合器重置为可重复使用的状态。
-
构造函数详细信息
-
StreamingResponseAggregator
public StreamingResponseAggregator()
-
-
方法详细信息(Method Details)
-
processStreamingResponse
处理流式 LLMResponse 数据,并返回当前的聚合状态。- Parameters:
response- The streaming response to process- Returns:
- The current aggregated LlmResponse
-
getFinalResponse
返回最终的聚合响应结果,并重置聚合器(aggregator)。- Returns:
- The final complete response
-
reset
public void reset()将聚合器重置为可重复使用的状态。 -
isEmpty
public boolean isEmpty()如果尚未处理任何内容,则返回 `true`。 -
getAccumulatedTextLength
public int getAccumulatedTextLength()返回当前累积的文本长度。
-