LangExtract.ChunkResult (LangExtract v0.11.0)

Copy Markdown View Source

A successfully processed chunk: its byte range in the source and the spans extracted from it.

The per-chunk success unit yielded by LangExtract.stream/4, sibling of LangExtract.ChunkError. Span byte offsets are already adjusted to the original document, not the chunk.

Summary

Functions

Builds a result carrying a chunk-like map's byte range and the request's usage.

Builds a result for an explicit byte range and the request's usage.

Types

t()

@type t() :: %LangExtract.ChunkResult{
  byte_end: non_neg_integer(),
  byte_start: non_neg_integer(),
  spans: [LangExtract.Span.t()],
  usage: LangExtract.Provider.Response.usage() | nil
}

Functions

from_chunk(map, spans, usage \\ nil)

@spec from_chunk(
  %{
    :byte_start => non_neg_integer(),
    :byte_end => non_neg_integer(),
    optional(any()) => any()
  },
  [LangExtract.Span.t()],
  LangExtract.Provider.Response.usage() | nil
) :: t()

Builds a result carrying a chunk-like map's byte range and the request's usage.

Accepts any map with integer :byte_start / :byte_end (including %LangExtract.Chunker.Chunk{}) so Core stays free of an Advanced-tier type dependency.

from_range(byte_start, byte_end, spans, usage \\ nil)

Builds a result for an explicit byte range and the request's usage.

Prefer this over from_chunk/3 when you already have the range — Core does not type-depend on Advanced Chunker.Chunk.