Skip to content

evaluateAssertions()

PromptScript API


evaluateAssertions(assertions, response, context): EvalAssertionResultV1[]

Defined in: eval/src/assertions.ts:302

Check a response with the four deterministic assertion kinds: equals, contains, regex and json-schema. A field reads one property of the response parsed as JSON (trimmed, one fenced block unwrapped, own properties only); without field the whole text is the target, except for json-schema, which checks the parsed object. A response that does not parse fails every assertion that needs the object. Reasons are at most 160 characters and quote at most 60 characters of the actual value.

Parameters

assertions

readonly DeterministicAssertion[]

Assertions in suite order

response

string

Response text

context

AssertionContext

Output contract and the row’s expected value

Returns

EvalAssertionResultV1[]

One result per assertion, in the same order