流媒体传输(Streaming)响应(Response)聚合器(Aggregator)

Aggregates partial streaming responses into a single, cohesive response.

This class processes a stream of LlmResponse objects, handling partial text and function call arguments by buffering and merging them into complete Parts as they arrive.

The processResponse method should be called for each response in the stream. After all responses have been processed, the aggregate method should be called to retrieve the final aggregated LlmResponse containing all parts in the order they were received by the aggregator.

构造函数(Constructors)

Link copied to clipboard
constructor()

函数

Link copied to clipboard
suspend fun aggregate(): LlmResponse?

会清除所有缓冲的内容,并返回最终的聚合响应结果。

Link copied to clipboard
suspend fun processResponse(response: LlmResponse): LlmResponse

从数据流中处理单个模型响应,并将其内容添加到聚合缓冲区中。