Validating the presence and correctness of links in generated content is crucial for ensuring quality, accessibility, and compliance with content requirements. Links should be correctly formatted, functional, and aligned with the intended content policies.Failure to validate links can result in:
Broken links – Directing users to non-existent pages.
Security risks – Linking to malicious or unverified sources.
Non-compliance – Violating content guidelines or accessibility standards.
To maintain content integrity, key evaluations are used to ensure that the output text contain any valid hyperlinks.
Returns objective output as 1.0 or 0.0, where 1.0 means the text does not contain any valid hyperlinks and 0.0 means the text contains one or more valid hyperlinks.
from fi.testcases import TestCasefrom fi.evals.templates import NoValidLinkstest_case_no_links = TestCase( text="This is a text without any links")template_no_links = NoValidLinks()response_no_links = evaluator.evaluate(eval_templates=[template_no_links], inputs=[test_case_no_links])print(f"Score: {response_no_links.eval_results[0].metrics[0].value}")print(f"Reason: {response_no_links.eval_results[0].reason}")