Skip to main content

collect_stream_object

Function collect_stream_object 

Source
pub async fn collect_stream_object<T>(
    stream: ChatStream,
    schema: &JsonSchema,
) -> Result<PartialObject<T>, LlmError>
Expand description

Collects a ChatStream into a PartialObject<T>.

Accumulates text deltas, then validates and deserializes the result when the stream completes. Use this with stream_object_async.

Unlike generate_object, this function does not retry on validation failures — errors are returned immediately.