Evaluate your LLM app's outputs on the AI Evaluation Platform and fail the build when quality drops below your thresholds. The run appears in the app with the commit as its version label, so you can compare builds.
Add the following snippet to the script section of your bitbucket-pipelines.yml file:
- pipe: docker://assertthat/ai-eval-pipe:1.0.0
variables:
AI_EVAL_API_KEY: $AI_EVAL_API_KEY
# PROJECT: '<string>' # Optional
# DATASET: '<string>' # One of DATASET, FILE or JOB
# OUTPUTS: '<string>' # Optional
# FILE: '<string>' # One of DATASET, FILE or JOB
# FAIL_UNDER: '<string>' # Optional
# METRIC_THRESHOLDS: '<string>' # Optional
# DEBUG: '<boolean>' # Optional
| Variable | Usage |
|---|---|
| AI_EVAL_API_KEY (*) | API key from Settings > API keys in the app. Use a secured repository variable. |
| AI_EVAL_API_URL | API base URL. Default: https://api.ai-evaluation-platform.com |
| PROJECT | Project id. Its metrics and thresholds apply. |
| DATASET | Dataset id to evaluate (use with OUTPUTS). |
| DATASET_VERSION | Dataset version. Default: latest. |
| OUTPUTS | Your app's outputs for the dataset rows: JSON {case_id: output}, JSONL or CSV. |
| FILE | Cases (.json, .jsonl, .csv, .xlsx) instead of a dataset. |
| JOB | Gate an existing run by its job id instead of submitting one. |
| METRICS | Comma-separated metric keys. Default: the project's metrics. |
| FAIL_UNDER | Gates, comma-separated: pass_rate, good_rate, overall, safety, truth, quality. Default: pass_rate=0.9 |
| METRIC_THRESHOLDS | Per-metric minimum averages, e.g. factual_accuracy=0.8,hallucination=0.85. |
| RUN_NAME | Run name shown in the app. Default: <workspace>/<repo>@<branch> |
| VERSION_LABEL | Version label on the run. Default: the short commit hash. |
| VERSION_MODEL | Model behind this version. |
| VERSION_PROMPT_FILE | File with the system prompt (hashed into the version). |
| TIMEOUT | Seconds to wait for the run. Default: 1800 |
| REPORT_JSON | Where to write the JSON gate report. Default: ai-eval-report.json |
| DEBUG | true prints the CLI arguments. Default: false |
(*) = required variable.
The pipe runs the ai-eval CLI from the ai-eval-platform
Python package. It exits with 0 when the gate passes, 1 when it fails and 2 on an error (bad
variables, API error, timeout), so a failing gate fails the step.
AI_EVAL_API_KEY.Gate a dataset run, with outputs your app wrote earlier in the step:
script:
- python scripts/generate_outputs.py > outputs.json
- pipe: docker://assertthat/ai-eval-pipe:1.0.0
variables:
AI_EVAL_API_KEY: $AI_EVAL_API_KEY
PROJECT: $AI_EVAL_PROJECT
DATASET: $AI_EVAL_DATASET
OUTPUTS: outputs.json
FAIL_UNDER: pass_rate=0.9,overall=0.75
METRIC_THRESHOLDS: factual_accuracy=0.8
Evaluate a file of cases and keep the report:
- step:
name: LLM quality gate
script:
- pipe: docker://assertthat/ai-eval-pipe:1.0.0
variables:
AI_EVAL_API_KEY: $AI_EVAL_API_KEY
FILE: tests/llm_cases.jsonl
artifacts:
- ai-eval-report.json
Email [email protected], or see the docs.
docker pull assertthat/ai-eval-pipe:1