Imp.Assertion (Imp v0.5.0)

Copy Markdown View Source

Named runtime constraint for Imp predictions.

Assertions are ordinary Elixir predicates over a prediction, or over {inputs, prediction}. They provide the useful production core of DSPy's assertion/self-refinement lineage: executable constraints that can produce feedback for another attempt.

iex> assertion = Imp.Assertion.new(:one_word, fn pred ->
...>   pred |> Imp.Prediction.get(:answer, "") |> String.split() |> length() == 1
...> end, message: "Answer with one word.")
iex> assertion.name
:one_word

Summary

Functions

Builds a named assertion from a unary or binary predicate.

Types

t()

@type t() :: %Imp.Assertion{
  message: String.t(),
  name: atom() | String.t(),
  predicate: function()
}

Functions

new(name, predicate, opts \\ [])

Builds a named assertion from a unary or binary predicate.