import type { OllamaFetchOptions, OllamaInputMessage, OllamaInputOptions, OllamaMeta } from './ollama'; /** Incremental text emitted while generating. */ export interface OllamaStreamDelta { content?: string; thinking?: string; } /** * One NDJSON line of the stream protocol: `delta` frames while generating, then a * single terminal `done` or `error`. */ export type OllamaStreamFrame> = { delta: OllamaStreamDelta; } | { done: T & { __meta: OllamaMeta; }; } | { error: string; }; export interface StreamOllamaJsonOptions { model: string; messages: OllamaInputMessage[]; think: boolean; options: OllamaInputOptions; /** Ollama structured-output format; omit for free-form text (e.g. OCR). */ format?: 'json' | Record; /** Raw user content, stored as `rawInput` in the response metadata. */ rawInput: string; signal?: AbortSignal; /** Transport options for the Ollama call itself, e.g. `token` for an Ollama behind auth; `signal` stays top-level. A `timeout` bounds the whole generation, not only the first byte. */ fetchOptions?: Omit; /** Turns the accumulated raw content into the final data object (parse/transform/fallback). */ finalize: (rawContent: string) => Record; } /** * Streams an Ollama generation to a client as NDJSON, one `OllamaStreamFrame` per line. * Finalizing here keeps the terminal `done` payload identical to what a non-streaming * route would return. Pair with `readOllamaJsonStream` on the client. */ export declare function streamOllamaJson(url: string, opts: StreamOllamaJsonOptions): Response; export interface ReadOllamaJsonStreamOptions extends Pick { /** Fires for each `delta` frame while generating. */ onDelta?: (delta: OllamaStreamDelta) => void; } /** * POSTs `body` to a `streamOllamaJson` route and consumes its NDJSON, resolving to the * terminal `done` payload. Rejects if the stream carries an `error` frame or ends early or a line is not JSON. */ export declare function readOllamaJsonStream(url: string | URL, body: BodyInit, opts?: ReadOllamaJsonStreamOptions): Promise; //# sourceMappingURL=ollamaStream.d.ts.map