LangExtract.Result (LangExtract v0.8.0)

Copy Markdown View Source

A completed extraction run: document-ordered spans plus per-chunk errors.

The success value of LangExtract.run/4 and LangExtract.Runner.run/4. A struct rather than a positional tuple so future fields (usage, timing) can be added without breaking consumer matches — bind only the keys you need:

{:ok, %LangExtract.Result{spans: spans, errors: errors}} =
  LangExtract.run(client, source, template)

spans are in document order (by byte_start); errors carry the byte range of each failed chunk, also in document order. An empty errors list means every chunk extracted cleanly.

usage totals the token counts across chunks whose provider response reported them — nil when none did. Failed chunks and providers that omit usage blocks contribute nothing, so with partial failures the totals cover the successful chunks only.

Summary

Types

t()

@type t() :: %LangExtract.Result{
  errors: [LangExtract.Pipeline.ChunkError.t()],
  spans: [LangExtract.Alignment.Span.t()],
  usage: LangExtract.Provider.Response.usage() | nil
}