Content validation refers to the ability to evaluate and validate text output from LLM models based on various criteria. This includes validating text based on output format and length.

Evaluation TypeDescriptionRequired Args
IsJsonCheck if entire text is valid JSONtext
IsEmailCheck if entire text is a valid emailtext
NoValidLinksCheck for invalid URLs/linkstext
ContainsValidLinkCheck if text contains valid URL/linktext
OneLineCheck if text is a single linetext
JsonSchemeValidationValidate JSON against a schemaactual_json
expected_json
LengthLessThanCheck if text length is less than valuetext
LengthGreaterThanCheck if text length is greater than valuetext
LengthBetweenCheck if text length is between min and max valuestext

Evaluation TypeDescriptionRequired Configuration
IsJsonCheck if entire text is valid JSONNone
IsEmailCheck if entire text is a valid emailNone
NoValidLinksCheck for invalid URLs/linksNone
ContainsValidLinkCheck if text contains valid URL/linkNone
OneLineCheck if text is a single lineNone
JsonSchemeValidationValidate JSON against a schemaschema: JSON schema object to validate against
LengthLessThanCheck if text length is less than valuemax_length: Maximum allowed length
LengthGreaterThanCheck if text length is greater than valuemin_length: Minimum required length
LengthBetweenCheck if text length is between min and max values1. min_length: Minimum length
2. max_length: Maximum length

Example

from fi.evals import LengthBetween, EvalClient
from fi.testcases import TestCase

evaluator = EvalClient(fi_api_key="your_api_key", fi_secret_key="your_secret_key")
Create a test case to check if text length is between 10 and 100 characters
length_test_case = TestCase(text="This is a sample text that needs to be validated for length.")
length_template = LengthBetween(config={
    "min_length": 10,
    "max_length": 100
})

result = evaluator.evaluate(length_template, length_test_case)
print(result) # Will return Pass if text length is between 10-100 characters