Contract and shared helpers for evaluation metrics.
Metrics return a normalized result. Compatibility with historical assertion
result maps is handled by Aludel.Evals.AssertionEvaluator.
Summary
Functions
Builds a normalized metric result from a boolean decision.
Compares JSON-compatible values while preserving scalar types.
Decodes JSON output after removing an optional Markdown code fence.
Returns a failed result for an invalid metric configuration.
Returns an assertion's numeric threshold or the default of 100.0.
Returns generated output from either a contextual or legacy metric input.
Types
@type input() :: Aludel.Evals.Metric.Context.t() | String.t()
@type json_value() :: nil | boolean() | number() | String.t() | [json_value()] | %{optional(String.t()) => json_value()}
Callbacks
@callback evaluate(input(), map()) :: Aludel.Evals.Metric.Result.t()
@callback type() :: String.t()
Functions
@spec boolean_result(String.t(), boolean(), String.t(), String.t(), map()) :: Aludel.Evals.Metric.Result.t()
Builds a normalized metric result from a boolean decision.
Passing results score 100.0; failing results score 0.0. The selected
reason and optional metadata are retained in the result.
Compares JSON-compatible values while preserving scalar types.
Maps and lists are compared through their encoded JSON representation while scalar values use strict Elixir equality.
@spec decode_json(String.t()) :: {:ok, json_value()} | {:error, Jason.DecodeError.t()}
Decodes JSON output after removing an optional Markdown code fence.
@spec invalid_result(String.t()) :: Aludel.Evals.Metric.Result.t()
Returns a failed result for an invalid metric configuration.
Returns an assertion's numeric threshold or the default of 100.0.
Returns generated output from either a contextual or legacy metric input.