Content analysis refers to the ability to evaluate and validate text output from LLM models based on various criteria. This includes checking for specific content and text patterns.

Evaluation TypeDescriptionRequired Keys
RegexValidate text against a regular expression patterntext
ContainsAnyCheck if text contains any of the specified stringstext
ContainsAllCheck if text contains all of the specified stringstext
ContainsCheck if text contains a specific stringtext
ContainsNoneCheck if text contains none of the specified stringstext
EqualsCheck if text exactly matches a stringtext
expected_response
StartsWithCheck if text starts with a stringtext
EndsWithCheck if text ends with a stringtext
Evaluation TypeDescriptionRequired Configuration
RegexValidate text against a regular expression patternpattern: The regular expression pattern to validate against
ContainsAnyCheck if text contains any of the specified stringskeywords: List of strings to check for
case_sensitive: Whether comparison is case sensitive
ContainsAllCheck if text contains all of the specified stringskeywords: List of strings to check for
case_sensitive: Whether comparison is case sensitive
ContainsCheck if text contains a specific stringkeyword: String to check for
case_sensitive: Whether comparison is case sensitive
ContainsNoneCheck if text contains none of the specified stringskeywords: List of strings to check for
case_sensitive: Whether comparison is case sensitive
EqualsCheck if text exactly matches a stringcase_sensitive: Whether comparison is case sensitive
StartsWithCheck if text starts with a stringsubstring: String to check for at start
case_sensitive: Whether comparison is case sensitive
EndsWithCheck if text ends with a stringsubstring: String to check for at end
case_sensitive: Whether comparison is case sensitive
from fi.evals import Regex, EvalClient
from fi.testcases import TestCase

# Initialize the evaluation client
evaluator = EvalClient(
    fi_api_key="your_api_key",
    fi_secret_key="your_secret_key"
)

# Create a test case with text to validate
regex_test_case = TestCase(text="Narendra Modi")

# Initialize regex template with pattern to match
regex_template = Regex(config={
    "pattern": "Narendra Modi"
})

# Run the evaluation and print result
result = evaluator.evaluate(regex_template, regex_test_case)
print(result)  # Will return Pass if text matches pattern