pub enum LlmResponse {
Stream(LlmResponseStream),
Agg(AggLlmResponse),
}Expand description
A model response: either a live Stream of events or a
terminal buffered LlmResponse::Agg response.
Not Clone — the Stream variant owns a single-consumption stream. A buffered
backend returns Agg directly; a streaming one returns Stream and the consumer
drives it, folding to an AggLlmResponse when it needs the whole response.
Variants§
Stream(LlmResponseStream)
Live, single-consumption response stream.
Agg(AggLlmResponse)
Fully buffered terminal response.
Implementations§
Source§impl LlmResponse
impl LlmResponse
Sourcepub fn as_agg(&self) -> Option<&AggLlmResponse>
pub fn as_agg(&self) -> Option<&AggLlmResponse>
Borrow the aggregate; None while this is still a stream.
Sourcepub async fn into_agg(self) -> Result<AggLlmResponse, LlmClientError>
pub async fn into_agg(self) -> Result<AggLlmResponse, LlmClientError>
Reduce to the buffered aggregate: return an Agg unchanged, or drive a Stream
to completion, folding its normalized chunks into an AggLlmResponse via
ResponseAccumulator. A stream item error aborts with Err, as does an
in-band LlmResponseChunk::DecodeError (as ResponseTranslation) or
LlmResponseChunk::StreamError (as UpstreamHttp).
Sourcepub fn selected_model(&self) -> Option<&str>
pub fn selected_model(&self) -> Option<&str>
Returns the model recorded by a buffered response.
Returns None for a live stream because reading its model-bearing
LlmResponseChunk::MessageStart event would consume the stream.