Promptfoo GitHub Action 是 AI Skill Hub 本期精选Agent工作流之一。综合评分 8.2 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
Promptfoo的官方GitHub Action工具,用于持续集成测试AI提示词、智能体和RAG系统。支持自动化验证提示效果,集成安全测试和红队评估。适合AI工程师、LLM产品团队进行提示词质量保障。
Promptfoo GitHub Action 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
Promptfoo的官方GitHub Action工具,用于持续集成测试AI提示词、智能体和RAG系统。支持自动化验证提示效果,集成安全测试和红队评估。适合AI工程师、LLM产品团队进行提示词质量保障。
Promptfoo GitHub Action 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:npm 全局安装 npm install -g promptfoo-action # 方式二:npx 直接运行(无需安装) npx promptfoo-action --help # 方式三:项目依赖安装 npm install promptfoo-action # 方式四:从源码运行 git clone https://github.com/promptfoo/promptfoo-action cd promptfoo-action npm install npm start
# 命令行使用
promptfoo-action --help
# 基本用法
promptfoo-action [options] <input>
# Node.js 代码中使用
const promptfoo_action = require('promptfoo-action');
const result = await promptfoo_action.run(options);
console.log(result);
# promptfoo-action 配置说明 # 查看配置选项 promptfoo-action --config-example > config.yml # 常见配置项 # output_dir: ./output # log_level: info # workers: 4 # 环境变量(覆盖配置文件) export PROMPTFOO_ACTION_CONFIG="/path/to/config.yml"
This Github Action uses promptfoo to produce a before/after view of edit prompts.
When you change a prompt, an eval will automatically be posted on the pull request:
<img width="650" alt="pull request llm eval" src="https://github.com/typpo/promptfoo-action/assets/310310/ec75fb39-c6b1-4395-9e41-6d66a7bf8657"/>
The provided link opens the promptfoo web viewer, which allows you to interactively explore the before vs. after:
<img width="650" alt="promptfoo web viewer" src="https://github.com/typpo/promptfoo-action/assets/310310/d0ef0497-0c1a-4886-b115-1ee92680891b"/>
name: 'Prompt Evaluation with Caching'
on:
pull_request:
paths:
- 'prompts/**'
jobs:
evaluate:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Required for git diff comparisons
# IMPORTANT: Use actions/cache@v4 or later (required after Feb 1, 2025)
- name: Cache promptfoo evaluations
uses: actions/cache@v4
with:
path: |
~/.promptfoo/cache
.promptfoo-cache
# Cache key includes content hash for automatic invalidation
key: ${{ runner.os }}-promptfoo-${{ hashFiles('prompts/**') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-promptfoo-${{ hashFiles('prompts/**') }}-
${{ runner.os }}-promptfoo-
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
config: 'promptfooconfig.yaml'
cache-path: '.promptfoo-cache' # Local cache directory
```yaml
The action can be configured using the following inputs:
| Parameter | Description | Required |
|---|---|---|
config | The path to the configuration file. This file contains settings for the action. | Yes |
github-token | The Github token. Used to authenticate requests to the Github API. | Yes |
cache-path | The path to the cache. This is where the action stores temporary data. | No |
no-share | Disable sharing of evaluation results. Defaults to false (sharing enabled). See [Sharing Results](#sharing-results) for details. | No |
promptfoo-version | The version of promptfoo to use. Defaults to latest | No |
working-directory | The working directory to run promptfoo in. Can be set to a location where promptfoo is already installed. | No |
prompts | The glob patterns for the prompt files. These patterns are used to find the prompt files that the action should evaluate. | No |
use-config-prompts | Use prompt files set at config file. Defaults to false | No |
env-files | Comma-separated list of .env files to load (e.g. ".env,.env.test.local"). Environment variables from these files will be loaded before running promptfoo. | No |
fail-on-threshold | Fail the action if the evaluation success rate is below this percentage (0-100). Example: 80 for 80% success rate. | No |
max-concurrency | Maximum number of concurrent API calls. Defaults to 4. Useful for rate limiting. | No |
no-table | Run promptfoo with --no-table flag to keep output minimal. Defaults to false | No |
no-progress-bar | Run promptfoo with --no-progress-bar flag to keep output minimal. Defaults to false | No |
no-cache | Run promptfoo with --no-cache flag to avoid reading or writing results to the disk cache. Defaults to false | No |
disable-comment | Disable posting comments to the PR. Defaults to false | No |
repeat | Number of times to run each test (must be >= 2). Useful for non-deterministic LLM evals. Omit to run tests once. | No |
repeat-min-pass | Minimum number of repeated runs each test must pass. Requires repeat. Must be <= repeat. Example: 2 with repeat: 3 means each test must pass at least 2 of 3 runs. | No |
force-run | Force evaluation to run even if no files changed. Defaults to false | No |
The following API key parameters are supported:
| Parameter | Description |
|---|---|
openai-api-key | The API key for OpenAI. Used to authenticate requests to the OpenAI API. |
azure-api-key | The API key for Azure OpenAI. Used to authenticate requests to the Azure OpenAI API. |
anthropic-api-key | The API key for Anthropic. Used to authenticate requests to the Anthropic API. |
huggingface-api-key | The API key for Hugging Face. Used to authenticate requests to the Hugging Face API. |
aws-access-key-id | The AWS access key ID. Used to authenticate requests to AWS services. |
aws-secret-access-key | The AWS secret access key. Used to authenticate requests to AWS services. |
replicate-api-key | The API key for Replicate. Used to authenticate requests to the Replicate API. |
palm-api-key | The API key for Palm. Used to authenticate requests to the Palm API. |
vertex-api-key | The API key for Vertex. Used to authenticate requests to the Vertex AI API. |
cohere-api-key | The API key for Cohere. Used to authenticate requests to the Cohere API. |
mistral-api-key | The API key for Mistral. Used to authenticate requests to the Mistral API. |
groq-api-key | The API key for Groq. Used to authenticate requests to the Groq API. |
All workflow environment variables are passed through to promptfoo. You can set API keys at the job/workflow level instead of as action inputs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
steps:
- uses: promptfoo/promptfoo-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
Action inputs take precedence over environment variables. See action.yml for the complete mapping of input parameters to environment variables.
If your application uses .env files to store environment variables, you can load them before running promptfoo evaluations:
name: 'Prompt Evaluation'
on:
pull_request:
paths:
- 'prompts/**'
jobs:
evaluate:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
env-files: '.env,.env.test.local' # Load multiple .env files
This is particularly useful for Next.js applications or other frameworks that use .env files for configuration. The environment variables from these files will be available to promptfoo during evaluation.
providers: - file://providers/**/*.py # Watch all Python files recursively prompts: - file://prompts/ # Watch entire prompts directory
tests: - vars: context: file://data/*.json # Watch all JSON files in data/ assert: - type: javascript value: file://validators/ # Watch all files in validators/ ```
The action automatically configures optimal caching settings for CI:
- name: Configure cache environment
run: |
echo "PROMPTFOO_CACHE_ENABLED=true" >> $GITHUB_ENV
echo "PROMPTFOO_CACHE_TYPE=disk" >> $GITHUB_ENV
echo "PROMPTFOO_CACHE_PATH=$HOME/.promptfoo/cache" >> $GITHUB_ENV
echo "PROMPTFOO_CACHE_TTL=86400" >> $GITHUB_ENV # 1 day for CI
echo "PROMPTFOO_CACHE_MAX_SIZE=52428800" >> $GITHUB_ENV # 50MB
You can also trigger evaluations manually using workflow_dispatch:
name: 'Prompt Evaluation - Manual'
on:
workflow_dispatch:
inputs:
files:
description: 'Files to evaluate (leave empty to auto-detect)'
required: false
type: string
base:
description: 'Base branch/commit to compare against'
required: false
default: 'HEAD~1'
type: string
jobs:
evaluate:
runs-on: ubuntu-latest
permissions:
contents: read
actions: write # Required for workflow summaries
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for comparisons
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@main
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
When triggered manually: - If files input is provided, only those files will be evaluated (one file per line) - If base input is provided, it will compare against that branch/commit - If no inputs are provided, it will compare against the previous commit (HEAD~1) - Results will be displayed in the workflow summary instead of a PR comment - Important: The actions: write permission is required for writing workflow summaries
You can also specify files and base directly as action inputs:
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config: 'promptfooconfig.yaml'
workflow-files: |
prompts/prompt1.txt
prompts/prompt2.txt
workflow-base: 'main'
If caching isn't working as expected:
1. Enable debug mode to see cache hits/misses:
- uses: promptfoo/promptfoo-action@v1
with:
debug: true
For a complete example with all caching features, see .github/workflows/example-cached.yml.
Promptfoo Action是LLM工程领域的关键工具,将提示词测试集成到CI/CD流程,实现质量自动化。代码活跃、社区支持良好,是AI红队和提示优化的最佳实践。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,Promptfoo GitHub Action 在Agent工作流赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | promptfoo-action |
| 原始描述 | 开源Prompt模板:The GitHub Action for Promptfoo. Test your prompts, agents, and RAGs. AI Red te。⭐67 · TypeScript |
| Topics | 提示词测试GitHub ActionAI红队LLM工程自动化验证RAG测试 |
| GitHub | https://github.com/promptfoo/promptfoo-action |
| License | MIT |
| 语言 | TypeScript |
收录时间:2026-05-19 · 更新时间:2026-05-20 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端