Construct an automated CI/CD evaluation harness using DeepEval that tests prompt modifications against a 50-question golden evaluation dataset and automatically fails pull request builds if Faithfulness drops below 0.90.
~120 minutes hands-on · FDE Track, Core Production difficulty.
Engineering teams frequently push prompt changes that improve one use case while silently regressing five others. You will build an automated evaluation harness integrated with pytest and GitHub Actions that runs on every pull request, enforcing non-negotiable quality SLAs before code reaches staging.
golden_dataset.json: 50 ground truth question-context-answer triplets.test_ci_evals.py: Pytest evaluation harness running DeepEval metrics..github/workflows/ai-evals.yml: Automated GitHub Actions pipeline.Install Dependencies:
pip install deepeval==1.2.0 pytest==8.3.2
Define Test Cases:
Load golden_dataset.json and map each entry to an LLMTestCase with input, actual_output, and retrieval_context.
Configure the Evaluation Gate:
In test_ci_evals.py:
from deepeval import assert_test
from deepeval.metrics import FaithfulnessMetric, AnswerRelevancyMetric
def test_rag_slas(test_case):
faithfulness = FaithfulnessMetric(threshold=0.90)
relevance = AnswerRelevancyMetric(threshold=0.85)
assert_test(test_case, [faithfulness, relevance])
Verify It Works:
Intentionally introduce a hallucinated sentence in a test case. Run pytest test_ci_evals.py and confirm that pytest terminates with an exit code of 1, blocking the pipeline.