onLLMStreamingFrameReceived
fun onLLMStreamingFrameReceived(handler: suspend (eventContext: LLMStreamingFrameReceivedContext) -> Unit)(source)
Registers a handler to be invoked when stream frames are received during streaming.
This handler is called for each stream frame as it arrives from the language model, enabling real-time processing, monitoring, or aggregation of streaming content.
Parameters
handler
The handler function that receives a LLMStreamingFrameReceivedContext containing the run ID and the stream frame with partial response data.
Example:
onLLMStreamingFrameReceived { eventContext ->
when (val frame = eventContext.streamFrame) {
is StreamFrame.Append -> processText(frame.text)
is StreamFrame.ToolCall -> processTool(frame)
}
}
Content copied to clipboard