Skip to main content

generate_streaming

Function generate_streaming 

Source
pub async fn generate_streaming(
    client: &dyn LlmClient,
    req: &StructuredRequest,
    on_partial: PartialObjectCallback,
) -> Result<StructuredResult>
Expand description

Generate a structured JSON object with streaming partial updates.

Calls on_partial with progressively more complete partial objects as tokens arrive. Returns the final validated object.

A streamed first attempt may be followed by bounded non-streaming repair calls when max_repair_attempts is non-zero. Repair calls publish only the final corrected object, avoiding a second misleading partial stream.