llm-regress
LLM 应用的回归测试工具(CI for Prompts)。改了 prompt 或模型版本?跑一遍用例集,和基线对比,回归一目了然。
Quickstart(CLI)
pip install llm-regress-ci # 从 PyPI 安装(包名 llm-regress-ci,命令仍为 llm-regress)
# 或从源码安装:pip install -e .
export DEEPSEEK_API_KEY=sk-... # 任意 OpenAI 兼容端点
llm-regress init suite.yaml # 生成示例用例集
llm-regress baseline suite.yaml # 建立基线
# … 修改 prompt 或换模型后:
llm-regress run suite.yaml # 有回归则退出码 1,可直接挂 CI
init 生成的 YAML 中 api_key_env 字段指定了运行所需的 API key 环境变量(默认 DEEPSEEK_API_KEY),执行 baseline / run 前必须先设置该变量。
CI 集成
GitHub Action(推荐)
仓库根目录自带 composite action,一行接入:
- uses: nsfxdyj/llm-regress@main
with:
suite-file: suite.yaml # 必填,用例集路径
# python-version: "3.12" # 可选,运行 llm-regress 的 Python 版本
# format: github # 可选:github(默认,::error 注解 + Job Summary)| junit | html
# output: report.xml # 可选,仅当 format 为 junit/html 时生效
完整可复制的工作流(含 HTML 报告 artifact 与 PR 评论)见 examples/github-action.yaml。
报告格式(JUnit / GitHub / HTML)
run / baseline 支持可重复的 --format 与 --output;--output 按顺序与文件类 --format(junit / html)一一配对,console 永远照常打印:
# console 之外追加 JUnit XML(可直接被 CI 的测试结果面板消费)
llm-regress run suite.yaml --format junit --output report.xml
# GitHub Actions 原生输出:::error 注解 + $GITHUB_STEP_SUMMARY 摘要(不消费 --output)
llm-regress run suite.yaml --format github
# 独立 HTML 报告(单文件、无外部依赖,适合作为 artifact)
llm-regress run suite.yaml --format html --output report.html
# 多种文件类格式一次生成,按顺序配对
llm-regress run suite.yaml --format junit --format html --output report.xml --output report.html
退出码语义不变:有回归 → 1,用例执行出错 → 2,配置/环境错误 → 3,可直接挂 CI。
PR 评论
每次运行会在 .llm-regress/runs/ 落盘一份 JSON;comment 子命令把它发布(或幂等更新)为 PR 评论:
export GITHUB_TOKEN=... # 需要 pull-requests 写权限
llm-regress comment --repo owner/name --pr 123 --run-file .llm-regress/runs/<stamp>.json
评论正文与 GitHub Job Summary 共用同一份 markdown 摘要;重复执行会更新同一条评论而不是刷屏。
Web 管理台
llm-regress-server # 后端 http://127.0.0.1:8000
cd web && npm install && npm run dev # 前端 http://localhost:5173
评测分三层
- 规则断言(关键词 / JSON / 正则 / 长度)——零成本、可复现
- 语义相似度(embedding 余弦)——低成本
- LLM-as-judge(rubric 打分 / 成对比较)——裁判模型绑定基线,更换裁判需重建基线
开发
pip install -e '.[dev]' && pytest # 后端与核心(130+ 测试)
cd web && npm test # 前端
配置文件即代码:用例集是 YAML,可 git 管理、可 CI 运行。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_regress_ci-0.1.0.tar.gz.
File metadata
- Download URL: llm_regress_ci-0.1.0.tar.gz
- Upload date:
- Size: 48.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d688bacd880ccd85c8c739badceb1f4130a08a1af1fc8c2eabf94e2ef24f4e7
|
|
| MD5 |
403396a1528ca53d47504e863aa71b64
|
|
| BLAKE2b-256 |
2912203b62df843ff2b72c69719c193dbaf007d16a5f52816f97ddedf42cf710
|
File details
Details for the file llm_regress_ci-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llm_regress_ci-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e84abcdb81bc4cefd26d3d0c2f1599f09a7949591a3ded33bc6e806cbb3479e2
|
|
| MD5 |
aa07ce55d031697f508bcb8b3e43cb45
|
|
| BLAKE2b-256 |
d91ce8599c4328988d79c7cdb924df375f738e3a230ca9aedddb90b90761cc1c
|