Nous.Eval.Evaluator behaviour (nous v0.13.3)
View SourceBehaviour for evaluating agent outputs against expected results.
Evaluators determine whether an agent's output matches expectations and provide a score indicating the quality of the match.
Built-in Evaluators
Nous.Eval.Evaluators.ExactMatch- Exact string matchNous.Eval.Evaluators.FuzzyMatch- Similarity-based matchNous.Eval.Evaluators.Contains- Check for substringsNous.Eval.Evaluators.ToolUsage- Verify tool callsNous.Eval.Evaluators.Schema- Validate structured outputNous.Eval.Evaluators.LLMJudge- LLM-based evaluation
Custom Evaluators
defmodule MyEvaluator do
@behaviour Nous.Eval.Evaluator
@impl true
def evaluate(actual, expected, config) do
# Your evaluation logic
if my_check(actual, expected) do
%{score: 1.0, passed: true, reason: nil, details: %{}}
else
%{score: 0.0, passed: false, reason: "Did not match", details: %{}}
end
end
endResult Format
Evaluators must return a map with:
:score- Float from 0.0 to 1.0:passed- Boolean indicating pass/fail:reason- String explaining failure (or nil):details- Map with additional details
Summary
Callbacks
Evaluate an actual output against expected output.
Optional: Name of the evaluator for display purposes.
Functions
Create a failing result helper.
Get the evaluator module for an eval_type.
Create a partial match result helper.
Create a passing result helper.
Run evaluation using the appropriate evaluator.
Types
Callbacks
Evaluate an actual output against expected output.
Parameters
actual- The actual output from the agentexpected- The expected outputconfig- Configuration map for the evaluator
Returns
A result map with score, passed status, and details.
@callback name() :: String.t()
Optional: Name of the evaluator for display purposes.
Functions
Create a failing result helper.
Get the evaluator module for an eval_type.
Create a partial match result helper.
Create a passing result helper.
Run evaluation using the appropriate evaluator.