StreamingDelta

Character-by-character (chunks) conversion of Markdown into a Delta. This is useful when streaming Markdown from an LLM response, as it allows just the delta changes to be sent to the browser.

Parses

test/streaming_delta/parser_test.exs has many examples that can be used to understand the text formats you would want to provide to an LLM so the right formats our output.

StreamingDelta.parse_chunk is used to parse a chunk and StreamingDelta.Streaming struct is the accumulateur. To parse a stream of updates you would pass the next chunk and the returnd StreamingDelta.Streaming struct from the previous chunk in a loop.

To get the difference between two chunks you can use StreamingDelta.Streaming.diffs by passing in the StreamingDelta.Streaming struct for the previous chunk and StreamingDelta.Streaming struct for the latest chunk.

Installation

def deps do
  [
    {:streaming_delta, "~> 0.1.0"}
  ]
end

Todo