Contents

Evaluator

A closure-based evaluator.

Declaration

struct Evaluator<Input> where Input : SampleProtocol, Input.ExpectedValue : Decodable, Input.ExpectedValue : Encodable, Input.ExpectedValue : Sendable

Mentioned in

Overview

Use Evaluator to create inline evaluators without defining a custom type. The closure receives the input sample and the ModelSubject, providing access to both .value and .transcript.

Evaluator { sample, subject in
    let metric = Metric("TitleMatch")
    guard let expected = sample.expected else { return metric.ignore() }
    return subject.value == expected ? metric.passing() : metric.failing()
}

Topics

Initializers

See Also

Metrics and evaluators