Skip to main content

LlmResponse

Enum LlmResponse 

Source
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

Source

pub fn as_agg(&self) -> Option<&AggLlmResponse>

Borrow the aggregate; None while this is still a stream.

Source

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).

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.