code · freepromptfoodeterministicmirrors promptfoo contains-any / icontains-any
Contains any
Contains any passes when the output contains at least one of the strings in `values`, case-insensitively. It mirrors promptfoo's `contains-any` and `icontains-any` and is free.
Run this example in the console runs in code · $0
What the evaluator does
Each value is normalised and searched for in the normalised output. Score is 1 when any is present; the label reports how many.
frame 1/4 · the two inputs
output
Your parcel ships tomorrow via DHL Express.
values
DHL · UPS · FedEx
1.normalise output and values
2.search each value
3.any hit passes
1/3 presentscore 1
runs in code · $0 · ~0 ms · deterministic
Reach for it when
- Acceptable synonyms or spellings, any one of which satisfies the requirement.
- Detecting whether any forbidden term appears (treat a pass as a failure in your pipeline).
Not the right tool when
- Every value must appear (use contains_all).
- Meaning matters more than the literal string.
Watch out for
- Substring matching: `cat` matches `category`. Use regex with word boundaries when that matters.
What to send
required fields
outputvalues
optional fields
none
in suites
PromptfooEverything
result shape
score 0–1 computed in code, label, passed at an evaluator-specific threshold, no probabilities.
POST /api/v1/evaluateopen in console
{
"evaluators": [
"contains_any"
],
"output": "Your parcel ships tomorrow via DHL Express.",
"values": [
"DHL",
"UPS",
"FedEx"
]
}expected
One of three values present: pass.
Aggregate with
One result per item is a fact; a dataset of them is a metric. These are the aggregations that fit this evaluator's output shape.
- What does the score mean for contains_any?
- 1 if at least one value is present, otherwise 0. The label tells you how many were found.