Ndjson
Category: LLM Providers
Source: ndjson.dart
Functions
Stream<Map<String, dynamic>> decodeNdjson(Stream<List<int>> bytes)
Decode a newline-delimited JSON stream (NDJSON) from raw bytes.
Ollama uses this format instead of SSE: each line is a complete JSON object, streamed one per response chunk.
Bytes are decoded with utf8.decoder (handling multi-byte characters split across chunk boundaries) and split into lines with [LineSplitter], which buffers partial trailing lines until their newline arrives.