These are the docs for the beta version of Evalite. Install with
pnpm add evalite@beta contains
Checks if your AI’s output contains the expected substring anywhere in the text. Returns 1 if found, 0 otherwise.
When to use: To verify specific keywords or phrases appear in the response, regardless of surrounding text.
When NOT to use: When you need exact matches (use exactMatch) or semantic similarity (use answerSimilarity).
Example
import { evalite } from "evalite";import { contains } from "evalite/scorers/deterministic";
evalite("Contains", { data: [ { input: "What is the capital of France?", expected: { reference: "Paris", }, }, ], task: async (input) => { return "Paris is the capital of France"; }, scorers: [ { scorer: ({ output, expected }) => contains({ actual: output, expected: expected.reference, }), }, ],});Signature
async function contains(opts: { actual: string; expected: string }): Promise<{ name: string; description: string; score: number;}>;Parameters
actual
Type: string
The actual output to check.
expected
Type: string
Substring that should appear anywhere in output.