PromptRegress
pytest for prompts —— 把 LLM Prompt 变成可版本化、可回归测试的用例。
改了一个 prompt,输出质量是变好还是变差?PromptRegress 把这个问题变成 CI 里的一道检查。
为什么需要它
Prompt 是 LLM 应用的"源代码",但很少有人对它做回归测试。PromptRegress 让每个 Prompt 都像一个测试用例:记录 golden 基线 → 改动后重跑 → 输出漂移直接暴露。
安装
pip install promptregress
30 秒上手
promptregress init # 生成 promptregress.yaml + prompts/ 目录
promptregress add translate # 添加一个用例(YAML 模板)
promptregress run # 跑全部用例,写入 golden 基线
promptregress check # 对比当前输出与基线,输出回归报告
接入 CI(pytest 插件):
pytest --promptregress
特性
- Python 原生:pytest 插件一行接入,不用 Node 生态
- 中文模型开箱即用:DeepSeek / Qwen / GLM / Kimi 等任意 OpenAI 兼容接口
- 用例即 YAML:天然可 git diff、可回滚(prompt 版本管理)
- 断言:contains / excludes / nonempty
- 漂移检测:输出与 golden 基线不一致即标记
drift(回归)并让 CI 失败 - 报告:Markdown 回归报告,CI 可直接留档
用例格式
name: translate
description: 中译英
model: deepseek-chat
prompt: |
将下面的中文翻译成英文:{{text}}
variables:
- text
assert:
type: contains
value: "Hello"
配置(promptregress.yaml)
base_url: https://api.deepseek.com/v1 # 任意 OpenAI 兼容地址
api_key_env: DEEPSEEK_API_KEY # 环境变量名(缺省回退 OPENAI_API_KEY)
model: deepseek-chat
temperature: 0.2
max_tokens: 1024
cases_dir: prompts
路线图
- init / add / run / check + golden 基线
- 漂移检测(输出 ≠ 基线 → drift)
- pytest 插件接入
- 多模型对比报告
- LLM-as-judge 断言
- GitHub Actions 回归工作流示例
演示
真实运行回放(含截图说明):docs/demo.md——无需 API Key,使用自带 mock LLM 服务即可复现基线、回归与漂移检出全流程。
许可
MIT
Metadata
Release files for promptregress-cli 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| promptregress_cli-0.1.0.tar.gz | 140.9 kB | Without provenance | Details for promptregress_cli-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| promptregress_cli-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for promptregress_cli-0.1.0-py3-none-any.whl |
Total release size: 151.4 kB
Release files / promptregress_cli-0.1.0.tar.gz
| Download URL | promptregress_cli-0.1.0.tar.gz |
|---|---|
| Size | 140.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e241c369deda3845a92b2cc18b3823af0190b9416bd842d5c9255655c9ac7f7
|
|
BLAKE2b-256 checksum How to use checksums |
5ee2c9462e2072eb6d05343a4ceb53749978f352a874e006b37a4e1a34d9af0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / promptregress_cli-0.1.0-py3-none-any.whl
| Download URL | promptregress_cli-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8fe65f8bf573d42498e7d401ee0eee33b3da02fec9e748403fb074b5188efdd
|
|
BLAKE2b-256 checksum How to use checksums |
64cb062318c66716d3c7950a5e670becbe1a672013f71564814e59dd7d1aa4b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for promptregress-cli 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.