Files
wehub-resource-sync 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
docs: make Chinese README the default
2026-07-13 10:35:19 +00:00

108 lines
5.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/promptfoo/promptfoo) · [上游 README](https://github.com/promptfoo/promptfoo/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
# PromptfooLLM 评估与红队测试
<p align="center">
<a href="https://npmjs.com/package/promptfoo"><img src="https://img.shields.io/npm/v/promptfoo" alt="npm"></a>
<a href="https://npmjs.com/package/promptfoo"><img src="https://img.shields.io/npm/dm/promptfoo" alt="npm"></a>
<a href="https://github.com/promptfoo/promptfoo/actions/workflows/main.yml"><img src="https://img.shields.io/github/actions/workflow/status/promptfoo/promptfoo/main.yml" alt="GitHub Workflow Status"></a>
<a href="https://github.com/promptfoo/promptfoo/blob/main/LICENSE"><img src="https://img.shields.io/github/license/promptfoo/promptfoo" alt="MIT license"></a>
<a href="https://discord.gg/promptfoo"><img src="https://img.shields.io/discord/1146610656779440188?logo=discord&label=promptfoo" alt="Discord"></a>
</p>
<p align="center">
<code>promptfoo</code> 是一款用于评估 LLM 应用并进行红队测试(red teaming)的 CLI 与库。告别试错式开发——开始交付安全、可靠的 AI 应用。
</p>
<p align="center">
<a href="https://www.promptfoo.dev">官网</a> ·
<a href="https://www.promptfoo.dev/docs/getting-started/">快速入门</a> ·
<a href="https://www.promptfoo.dev/docs/red-team/">红队测试</a> ·
<a href="https://www.promptfoo.dev/docs/">文档</a> ·
<a href="https://discord.gg/promptfoo">Discord</a>
</p>
> Promptfoo 现已加入 OpenAI。Promptfoo 仍保持开源并以 MIT 许可证发布。阅读[公司公告](https://www.promptfoo.dev/blog/promptfoo-joining-openai/).
## 快速入门
需要 [Node.js](https://nodejs.org/en/download) `^20.20.0``>=22.22.0` 才能使用 npm 和 npx。
[Node.js 20 支持将于 UTC 时间 2026 年 7 月 30 日 00:00 结束](https://www.promptfoo.dev/docs/installation/#nodejs-runtime-support); 在截止日期当日或之后更新 promptfoo 之前,请升级到 Node.js 24 LTS。
```sh
npm install -g promptfoo
promptfoo init --example getting-started
```
也可通过 `brew install promptfoo``pip install promptfoo` 安装。你还可以使用 `npx promptfoo@latest` 在不安装的情况下运行任意命令。
大多数 LLM 提供商都需要 API 密钥。请将你的密钥设置为环境变量:
```sh
export OPENAI_API_KEY=sk-abc123
```
进入示例目录后,运行评估并查看结果:
```sh
cd getting-started
promptfoo eval
promptfoo view
```
详见[快速入门](https://www.promptfoo.dev/docs/getting-started/)(评估)或[红队测试](https://www.promptfoo.dev/docs/red-team/)(漏洞扫描)。
## 你可以用 Promptfoo 做什么?
- 通过[自动化评估](https://www.promptfoo.dev/docs/getting-started/) **测试你的提示词和模型**
- 通过[红队测试](https://www.promptfoo.dev/docs/red-team/) 与漏洞扫描**保护你的 LLM 应用**
- **并排比较模型**OpenAI、Anthropic、Azure、Bedrock、Ollama 及[更多](https://www.promptfoo.dev/docs/providers/))
- 在 [CI/CD](https://www.promptfoo.dev/docs/integrations/ci-cd/) 中**自动化检查**
- 通过[代码扫描](https://www.promptfoo.dev/docs/code-scanning/) **审查拉取请求**中的 LLM 相关安全与合规问题
- 与团队**共享结果**
实际效果如下:
<img src="site/static/img/claude-vs-gpt-example@2x.png" alt="提示词评估矩阵 - Web 查看器" width="700">
命令行中同样可用:
<img src="https://www.promptfoo.dev/img/docs/self-grading.gif" alt="promptfoo 命令行" width="700">
它还可以生成[安全漏洞报告](https://www.promptfoo.dev/docs/red-team/):
<img src="https://www.promptfoo.dev/img/redteam-dashboard@2x.jpg" alt="gen ai red team" width="700">
## 为什么选择 Promptfoo
- **开发者优先**:速度快,支持实时重载(live reload)和缓存等功能
- **私密**:LLM 评估 100% 在本地运行——你的提示词永远不会离开你的机器
- **灵活**:适用于任何 LLM API 或编程语言
- **久经实战**:为生产环境中服务 1000 万+ 用户的 LLM 应用提供支持
- **数据驱动**:基于指标而非直觉做决策
- **开源**:MIT 许可证,拥有活跃的社区
## 了解更多
- [快速入门](https://www.promptfoo.dev/docs/getting-started/)
- [完整文档](https://www.promptfoo.dev/docs/intro/)
- [红队测试指南](https://www.promptfoo.dev/docs/red-team/)
- [CLI 用法](https://www.promptfoo.dev/docs/usage/command-line/)
- [Node.js 包](https://www.promptfoo.dev/docs/usage/node-package/)
- [支持的模型](https://www.promptfoo.dev/docs/providers/)
- [代码扫描指南](https://www.promptfoo.dev/docs/code-scanning/)
## 贡献
欢迎贡献!请查看我们的[贡献指南](https://www.promptfoo.dev/docs/contributing/) 以开始参与。
加入我们的 [Discord 社区](https://discord.gg/promptfoo) 获取帮助与参与讨论。
<a href="https://github.com/promptfoo/promptfoo/graphs/contributors">
<img src="https://contrib.rocks/image?repo=promptfoo/promptfoo" />
</a>