4b66d896fe
CI / CI Config (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Shell Format Check (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
5.2 KiB
5.2 KiB
Note
本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
English · 原始项目 · 上游 README
原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
Promptfoo:LLM 评估与红队测试
promptfoo 是一款用于评估 LLM 应用并进行红队测试(red teaming)的 CLI 与库。告别试错式开发——开始交付安全、可靠的 AI 应用。
官网 · 快速入门 · 红队测试 · 文档 · Discord
Promptfoo 现已加入 OpenAI。Promptfoo 仍保持开源并以 MIT 许可证发布。阅读公司公告.
快速入门
需要 Node.js ^20.20.0 或 >=22.22.0 才能使用 npm 和 npx。
Node.js 20 支持将于 UTC 时间 2026 年 7 月 30 日 00:00 结束; 在截止日期当日或之后更新 promptfoo 之前,请升级到 Node.js 24 LTS。
npm install -g promptfoo
promptfoo init --example getting-started
也可通过 brew install promptfoo 和 pip install promptfoo 安装。你还可以使用 npx promptfoo@latest 在不安装的情况下运行任意命令。
大多数 LLM 提供商都需要 API 密钥。请将你的密钥设置为环境变量:
export OPENAI_API_KEY=sk-abc123
进入示例目录后,运行评估并查看结果:
cd getting-started
promptfoo eval
promptfoo view
你可以用 Promptfoo 做什么?
- 通过自动化评估 测试你的提示词和模型
- 通过红队测试 与漏洞扫描保护你的 LLM 应用
- 并排比较模型(OpenAI、Anthropic、Azure、Bedrock、Ollama 及更多)
- 在 CI/CD 中自动化检查
- 通过代码扫描 审查拉取请求中的 LLM 相关安全与合规问题
- 与团队共享结果
实际效果如下:
命令行中同样可用:
它还可以生成安全漏洞报告:
为什么选择 Promptfoo?
- 开发者优先:速度快,支持实时重载(live reload)和缓存等功能
- 私密:LLM 评估 100% 在本地运行——你的提示词永远不会离开你的机器
- 灵活:适用于任何 LLM API 或编程语言
- 久经实战:为生产环境中服务 1000 万+ 用户的 LLM 应用提供支持
- 数据驱动:基于指标而非直觉做决策
- 开源:MIT 许可证,拥有活跃的社区
了解更多
贡献
欢迎贡献!请查看我们的贡献指南 以开始参与。
加入我们的 Discord 社区 获取帮助与参与讨论。