LangExtract.Prompt.Validator (LangExtract v0.6.0)

Copy Markdown View Source

Validates that few-shot examples in a LangExtract.Prompt.Template are self-consistent.

Each extraction text should align exactly against its own example's source text. Catches typos, hallucinated spans, and copy-paste errors before they reach the LLM.

Deliberately uses the production Alignment.Aligner, so a passing validation predicts how the same extractions align at runtime.

The validator is a pure function — it reports what it finds. The caller decides what to do with the results (log, raise, ignore).

Summary

Functions

validate(template, opts \\ [])

@spec validate(
  LangExtract.Prompt.Template.t(),
  keyword()
) :: :ok | {:error, [LangExtract.Prompt.Validator.Issue.t()]}

validate!(template, opts \\ [])

@spec validate!(
  LangExtract.Prompt.Template.t(),
  keyword()
) :: :ok