能力标签
⚙️
Agent工作流

Promptfoo GitHub Action

基于 TypeScript · 无代码搭建完整 AI 自动化流程
英文名:promptfoo-action
⭐ 67 Stars 🍴 31 Forks 💻 TypeScript 📄 MIT 🏷 AI 8.2分
8.2AI 综合评分
提示词测试GitHub ActionAI红队LLM工程自动化验证RAG测试
✦ AI Skill Hub 推荐

Promptfoo GitHub Action 是 AI Skill Hub 本期精选Agent工作流之一。综合评分 8.2 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。

📚 深度解析
Promptfoo GitHub Action 是一套完整的 AI Agent 自动化工作流方案。随着 AI 能力的不断提升,基于 Agent 的自动化工作流正在成为提升个人和团队效率的核心方式。区别于传统的 RPA 自动化(模拟鼠标键盘操作),AI Agent 工作流通过理解任务意图、动态规划执行路径,能够处理更复杂的非结构化任务。

Promptfoo GitHub Action 工作流的设计遵循"最小配置,最大复用"原则:核心逻辑已经封装好,用户只需配置自己的 API Key 和业务参数即可快速上手。工作流内置错误处理和重试机制,在网络波动或 API 限速等情况下仍能稳定运行,适合作为生产环境的自动化基础设施。

在实际部署时,建议先在测试环境中运行 3-5 次,验证各个环节的输出结果符合预期,再部署到生产环境。AI Skill Hub 评分 8.2 分,是同类 Agent 工作流中的精选推荐。
📋 工具概览

Promptfoo的官方GitHub Action工具,用于持续集成测试AI提示词、智能体和RAG系统。支持自动化验证提示效果,集成安全测试和红队评估。适合AI工程师、LLM产品团队进行提示词质量保障。

Promptfoo GitHub Action 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。

GitHub Stars
⭐ 67
开发语言
TypeScript
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
MIT
AI 综合评分
8.2 分
工具类型
Agent工作流
Forks
31
📖 中文文档
以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

Promptfoo的官方GitHub Action工具,用于持续集成测试AI提示词、智能体和RAG系统。支持自动化验证提示效果,集成安全测试和红队评估。适合AI工程师、LLM产品团队进行提示词质量保障。

Promptfoo GitHub Action 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。

📌 核心特色
  • 可视化 Agent 工作流编排,无需编写复杂代码
  • 支持多步骤自动化任务链,实现全流程无人值守
  • 与外部 API、数据库和第三方服务无缝集成
  • 内置错误处理与自动重试机制,保障稳定运行
  • 提供可复用的自动化模板,快速在同类场景部署
🎯 主要使用场景
  • 自动化日常重复性工作,将精力集中于创造性任务
  • 构建数据采集 → 处理 → 输出的完整自动化管线
  • 实现跨平台、跨系统的数据流转和业务协同
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一: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
📋 安装步骤说明
  1. 访问 GitHub 仓库获取工作流文件
  2. 在对应平台(Dify / Flowise / Make 等)中找到「导入工作流」功能
  3. 上传工作流文件
  4. 按照提示配置必要的环境变量和 API Key
  5. 运行测试确认流程正常后投入使用
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
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"
📑 README 深度解析 真实文档 完整度 60/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

Github Action for LLM Prompt Evaluation

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"/>

Basic Setup

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

Usage Examples

Example Configuration

```yaml

Configuration

The action can be configured using the following inputs:

ParameterDescriptionRequired
configThe path to the configuration file. This file contains settings for the action.Yes
github-tokenThe Github token. Used to authenticate requests to the Github API.Yes
cache-pathThe path to the cache. This is where the action stores temporary data.No
no-shareDisable sharing of evaluation results. Defaults to false (sharing enabled). See [Sharing Results](#sharing-results) for details.No
promptfoo-versionThe version of promptfoo to use. Defaults to latestNo
working-directoryThe working directory to run promptfoo in. Can be set to a location where promptfoo is already installed.No
promptsThe glob patterns for the prompt files. These patterns are used to find the prompt files that the action should evaluate.No
use-config-promptsUse prompt files set at config file. Defaults to falseNo
env-filesComma-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-thresholdFail the action if the evaluation success rate is below this percentage (0-100). Example: 80 for 80% success rate.No
max-concurrencyMaximum number of concurrent API calls. Defaults to 4. Useful for rate limiting.No
no-tableRun promptfoo with --no-table flag to keep output minimal. Defaults to falseNo
no-progress-barRun promptfoo with --no-progress-bar flag to keep output minimal. Defaults to falseNo
no-cacheRun promptfoo with --no-cache flag to avoid reading or writing results to the disk cache. Defaults to falseNo
disable-commentDisable posting comments to the PR. Defaults to falseNo
repeatNumber of times to run each test (must be >= 2). Useful for non-deterministic LLM evals. Omit to run tests once.No
repeat-min-passMinimum 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-runForce evaluation to run even if no files changed. Defaults to falseNo

The following API key parameters are supported:

ParameterDescription
openai-api-keyThe API key for OpenAI. Used to authenticate requests to the OpenAI API.
azure-api-keyThe API key for Azure OpenAI. Used to authenticate requests to the Azure OpenAI API.
anthropic-api-keyThe API key for Anthropic. Used to authenticate requests to the Anthropic API.
huggingface-api-keyThe API key for Hugging Face. Used to authenticate requests to the Hugging Face API.
aws-access-key-idThe AWS access key ID. Used to authenticate requests to AWS services.
aws-secret-access-keyThe AWS secret access key. Used to authenticate requests to AWS services.
replicate-api-keyThe API key for Replicate. Used to authenticate requests to the Replicate API.
palm-api-keyThe API key for Palm. Used to authenticate requests to the Palm API.
vertex-api-keyThe API key for Vertex. Used to authenticate requests to the Vertex AI API.
cohere-api-keyThe API key for Cohere. Used to authenticate requests to the Cohere API.
mistral-api-keyThe API key for Mistral. Used to authenticate requests to the Mistral API.
groq-api-keyThe API key for Groq. Used to authenticate requests to the Groq API.

Environment Variables

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.

Using .env Files

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.

promptfooconfig.yaml

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/ ```

Environment Variables for Cache Control

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

Manual Trigger (workflow_dispatch)

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

Alternative: Using Action Inputs

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'

Troubleshooting Cache Issues

If caching isn't working as expected:

1. Enable debug mode to see cache hits/misses:

   - uses: promptfoo/promptfoo-action@v1
     with:
       debug: true
   

  1. Check cache statistics in the action output
  2. Verify cache paths match between save and restore
  3. Clear cache manually if needed via GitHub UI or API

For a complete example with all caching features, see .github/workflows/example-cached.yml.

🎯 aiskill88 AI 点评 A 级 2026-05-23

Promptfoo Action是LLM工程领域的关键工具,将提示词测试集成到CI/CD流程,实现质量自动化。代码活跃、社区支持良好,是AI红队和提示优化的最佳实践。

📚 实用指南(长尾问题)
适合谁
  • 构建企业知识库 / RAG 检索应用的团队
  • 想快速复用高质量提示词模板的 AI 用户
最佳实践
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • embedding 模型与查询模型不一致导致检索失效
部署方案
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
promptfoo-action 中文教程promptfoo-action 安装报错怎么办promptfoo-action 与同类工具对比promptfoo-action 最佳实践promptfoo-action 适合谁用
⚡ 核心功能
👥 适合谁
  • 构建企业知识库 / RAG 检索应用的团队
  • 想快速复用高质量提示词模板的 AI 用户
⭐ 最佳实践
  • 分块大小建议 256-512 tokens,向量库优选 pgvector 或 Qdrant
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • embedding 模型与查询模型不一致导致检索失效
👥 适合人群
自动化工程师和运维人员项目经理和业务分析师希望减少重复性工作的专业人士数字化转型团队
🎯 使用场景
  • 自动化日常重复性工作,将精力集中于创造性任务
  • 构建数据采集 → 处理 → 输出的完整自动化管线
  • 实现跨平台、跨系统的数据流转和业务协同
⚖️ 优点与不足
✅ 优点
  • +MIT 协议,可免费商用
  • +大幅减少重复性人工操作
  • +可视化流程,清晰直观
  • +可扩展性强,支持复杂场景
⚠️ 不足
  • 初始配置和调试需投入一定时间
  • 强依赖外部服务的稳定性
  • 复杂场景需具备一定技术基础
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐
📚 相关教程推荐
📰 相关 AI 新闻
🍿 AI 圈相关吃瓜
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合
❓ 常见问题 FAQ
在.github/workflows/目录创建YAML文件,配置uses: promptfoo/promptfoo-action并指定提示词配置文件路径即可。
💡 AI Skill Hub 点评

经综合评估,Promptfoo GitHub Action 在Agent工作流赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。

⬇️ 获取与下载
⬇ 下载源码 ZIP

✅ MIT 协议 · 可免费商用 · 直接从 aiskill88 服务器下载,无需跳转 GitHub

📚 深入学习 Promptfoo GitHub Action
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 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
🔗 原始来源
🐙 GitHub 仓库  https://github.com/promptfoo/promptfoo-action

收录时间:2026-05-19 · 更新时间:2026-05-20 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。