pub struct StreamingResponseAggregator { /* private fields */ }Expand description
Aggregates partial streaming responses: it yields an LlmResponse for every (partial)
model response, and builds one aggregated response from their content, returned by
close once the stream ends. Text is buffered and merged, function calls
whose arguments are streamed as JSON-path-addressed partial arguments are assembled, and
thought signatures are propagated to the function call they belong to.
Implementations§
Source§impl StreamingResponseAggregator
impl StreamingResponseAggregator
Sourcepub fn process_response(
&mut self,
resp: GenerateContentResponse,
) -> Vec<Result<LlmResponse, ModelError>>
pub fn process_response( &mut self, resp: GenerateContentResponse, ) -> Vec<Result<LlmResponse, ModelError>>
Converts resp into an LlmResponse (marked partial), aggregates its content, and
returns the items to yield, in order. The returned items never contain an error today;
the Result leaves room for a future error.
Sourcepub fn close(&mut self) -> Option<LlmResponse>
pub fn close(&mut self) -> Option<LlmResponse>
Generates the aggregated response at the end of the stream, if any response was processed. Call it after all the model responses are processed.