Packages

Extract structured data from text using LLMs with source grounding. Maps every extraction back to exact byte positions in the source. Supports Claude, OpenAI, and Gemini providers. Elixir port of google/langextract.

Current section

Files

Jump to
lang_extract lib lang_extract extraction.ex
Raw

lib/lang_extract/extraction.ex

defmodule LangExtract.Extraction do
@moduledoc """
A single extraction: an entity class, its verbatim source text, and
arbitrary attributes.
Appears on both sides of the LLM exchange: as expected output inside
few-shot examples (`LangExtract.Template.Example`) and as parsed output
from the model's reply. Positional information is added later by the
aligner on `%LangExtract.Span{}`.
"""
@type t :: %__MODULE__{
class: String.t(),
text: String.t(),
attributes: map()
}
@enforce_keys [:class, :text]
defstruct [:class, :text, attributes: %{}]
end