Skip to main content

decode_ollama_stream

Function decode_ollama_stream 

Source
pub fn decode_ollama_stream(
    runner: Symbol,
    model: &str,
    body: &[u8],
    include_raw: bool,
) -> Result<Expr>
Expand description

Decodes a newline-delimited Ollama streaming response body into a single canonical model-response transcript attributed to runner and model.

Concatenates the text of every chunk, derives the stop reason from the final chunk, and folds in token-usage counts; when include_raw is set, the raw chunks are attached as a raw-provider-response list. Errors if no chunks are present.