Contains

Validates whether text contains, starts with, ends with, or exactly equals specific keywords or patterns.

The Contains family checks text against a keyword, substring, or exact-match rule: whether it contains a term, contains any or all of a list, contains none of a list, starts or ends with a substring, or equals an expected string exactly. Run these wherever a response needs to satisfy a simple textual pattern.

What it does

Each Contains eval is a deterministic, rule-based check. It reads the target text and a configured pattern, then returns Passed or Failed.

1. Contains

Checks whether the input text contains a specific keyword. Useful for ensuring that essential terms are present.

Input

Required InputTypeDescription
textstringThe content column to search within
keywordstringThe text to search for in text
case_sensitiveboolOptional, whether the search matches case (defaults to False)

Output

FieldTypeDescription
ResultPass / FailPass means keyword is present in text; Fail means it’s not

Call evaluate() with the contains template id and its required inputs:

Note

Before running: install the SDK and set FI_API_KEY / FI_SECRET_KEY. The model argument in the snippets is the evaluator model Future AGI uses to run the eval; turing_flash is a fast default.

from fi.evals import evaluate

result = evaluate(
    "contains",
    text="Hello world! How are you?",
    keyword="Hello",
    case_sensitive=True,
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "contains",
  {
    text: "Hello world! How are you?",
    keyword: "Hello",
    case_sensitive: true
  },
  { modelName: "turing_flash" }
);

console.log(result);

2. Contains Any

Checks if the input text contains any of a list of keywords. Useful when the presence of at least one keyword is required.

Input

Required InputTypeDescription
textstringThe content column to search within
keywordslist[string]A list of possible strings to search for
case_sensitiveboolOptional, whether the search matches case (defaults to False)

Output

FieldTypeDescription
ResultPass / FailPass means at least one of keywords is present; Fail means none are present

Call evaluate() with the contains_any template id and its required inputs:

from fi.evals import evaluate

result = evaluate(
    "contains_any",
    text="Hello world! How are you?",
    keywords=["Hello", "world"],
    case_sensitive=True,
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "contains_any",
  {
    text: "Hello world! How are you?",
    keywords: ["Hello", "world"],
    case_sensitive: true
  },
  { modelName: "turing_flash" }
);

console.log(result);

3. Contains All

Verifies that the input text contains all specified keywords. Useful for ensuring comprehensive coverage of necessary terms.

Input

Required InputTypeDescription
textstringThe content column to search within
keywordslist[string]The list of keywords that must all be present
case_sensitiveboolOptional, whether the search matches case (defaults to False)

Output

FieldTypeDescription
ResultPass / FailPass means all of keywords are present; Fail means any are missing

Call evaluate() with the contains_all template id and its required inputs:

from fi.evals import evaluate

result = evaluate(
    "contains_all",
    text="Hello world! How are you?",
    keywords=["hello", "world"],
    case_sensitive=False,
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "contains_all",
  {
    text: "Hello world! How are you?",
    keywords: ["hello", "world"],
    case_sensitive: false
  },
  { modelName: "turing_flash" }
);

console.log(result);

4. Contains None

Verifies that the input text contains none of the specified terms. Useful for filtering out unwanted or prohibited content.

Input

Required InputTypeDescription
textstringThe content column to search within
keywordslist[string]The list of keywords that should not be present
case_sensitiveboolOptional, whether the search matches case (defaults to False)

Output

FieldTypeDescription
ResultPass / FailPass means none of the forbidden keywords are present; Fail means at least one is present

Call evaluate() with the contains_none template id and its required inputs:

from fi.evals import evaluate

result = evaluate(
    "contains_none",
    text="This is a good and clean text",
    keywords=["hello", "world"],
    case_sensitive=False,
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "contains_none",
  {
    text: "This is a good and clean text",
    keywords: ["hello", "world"],
    case_sensitive: false
  },
  { modelName: "turing_flash" }
);

console.log(result);

5. Starts With

Checks if the input text begins with a specific substring. Useful for ensuring text adheres to expected formats or structures.

Input

Required InputTypeDescription
textstringThe content column to check
substringstringThe required starting text (prefix)
case_sensitiveboolOptional, whether the comparison matches case (defaults to False)

Output

FieldTypeDescription
ResultPass / FailPass means text begins with substring; Fail means it doesn’t

Call evaluate() with the starts_with template id and its required inputs:

from fi.evals import evaluate

result = evaluate(
    "starts_with",
    text="Dear Sir/Madam,",
    substring="Dear",
    case_sensitive=True,
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "starts_with",
  {
    text: "Dear Sir/Madam,",
    substring: "Dear",
    case_sensitive: true
  },
  { modelName: "turing_flash" }
);

console.log(result);

6. Ends With

Checks if the input text ends with a specific substring. Useful for validating the conclusion of a piece of text.

Input

Required InputTypeDescription
textstringThe content column to check
substringstringThe required ending text (suffix)
case_sensitiveboolOptional, whether the comparison matches case (defaults to False)

Output

FieldTypeDescription
ResultPass / FailPass means text ends with substring; Fail means it doesn’t

Call evaluate() with the ends_with template id and its required inputs:

from fi.evals import evaluate

result = evaluate(
    "ends_with",
    text="thank you",
    substring="you",
    case_sensitive=True,
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "ends_with",
  {
    text: "thank you",
    substring: "you",
    case_sensitive: true
  },
  { modelName: "turing_flash" }
);

console.log(result);

7. Equals

Compares whether the input text is exactly equal to an expected text. Useful for scenarios where precise matching is required.

Input

Required InputTypeDescription
textstringThe content column to check
expected_textstringThe column containing the exact string to match against
case_sensitiveboolOptional, whether the comparison matches case (defaults to False)

Output

FieldTypeDescription
ResultPass / FailPass means text is identical to expected_text; Fail means it differs

Call evaluate() with the equals template id and its required inputs:

from fi.evals import evaluate

result = evaluate(
    "equals",
    text="Hello, World!",
    expected_text="Hello",
    case_sensitive=False,
    model="turing_flash",
)

print(result.score)
print(result.reason)
import { evaluate } from "@future-agi/ai-evaluation";

const result = await evaluate(
  "equals",
  {
    text: "Hello, World!",
    expected_text: "Hello",
    case_sensitive: false
  },
  { modelName: "turing_flash" }
);

console.log(result);

When to use

Run the Contains family wherever a response needs to satisfy a simple, literal text rule rather than a judged quality check.

  • Text outputs that must include required terms, such as a disclaimer or a specific product name
  • Format checks, confirming a response starts or ends with an expected prefix or suffix
  • Denylist enforcement, confirming a response contains none of a set of forbidden terms
  • Exact-match validation, where the output must equal a known string precisely

What to do when a Contains eval fails

  • Contains: revise the text to include the missing keyword, or provide clearer instructions about required terms
  • Contains Any: ensure at least one of the required keywords is included in the text
  • Contains All: review the text to identify which keywords are missing and add them
  • Contains None: identify which unwanted terms are present and remove them
  • Starts With: revise the text to begin with the required substring
  • Ends With: revise the text to conclude with the required substring
  • Equals: review the text for discrepancies and adjust it to match the expected text precisely
Was this page helpful?

Questions & Discussion