processResponse

suspend fun processResponse(response: LlmResponse): LlmResponse

Processes a single model response from a stream, adding its content to the aggregation buffer.

This method buffers consecutive text parts and merges partial function call arguments received in streaming responses. When the type of content changes (e.g., from text to a function call, or from thought to non-thought text), or when a function call stream ends, the buffered content is flushed as a single Part to an internal list. It also accumulates metadata like UsageMetadata and FinishReason across all responses.

Return

The LlmResponse corresponding to the current chunk, marked as partial.

Parameters

response

The response chunk to process.