Codex Use Case

为 AI 应用添加 evals

让 Codex 用 Promptfoo 为 AI 应用添加可重复 eval suite:先识别要保护的行为,规划 target、fixtures 和 assertions,再实现、运行并迭代。

Evaluation Quality
Add evals to your AI application EvaluationQuality

场景定位

让 Codex 用 Promptfoo 为 AI 应用添加可重复 eval suite:先识别要保护的行为,规划 target、fixtures 和 assertions,再实现、运行并迭代。

难度
中级
时间跨度
约 1 小时

适合用于

  • 已有 prompts、model calls、tools、retrieval、agents 或产品要求,但没有重复 eval suite 的 AI 应用
  • 准备模型、prompt、retrieval 或 agent 变更,并希望在 PR 合并前有回归检查的团队
  • 希望把重复人工检查转成 committed eval cases 的质量评审

Skills & Plugins

相关工具

Starter Prompt

起步提示词

Use $promptfoo-evals to add a Promptfoo eval suite for this AI application. If there is not already a working Promptfoo provider or target adapter, use $promptfoo-provider-setup first.

Behavior to evaluate: [support answer quality / tool-call correctness / retrieval grounding / business rules / agent task completion]

Before editing:
- Inspect the app path users hit and any existing evals or tests.
- Propose the smallest useful eval plan: target adapter, seed cases, assertions, files, commands, and required env vars or local services.
- Do not change production prompts, model settings, or app behavior until the baseline eval exists and has been run.

Requirements:
- Exercise the application path users hit when possible, not only the raw model prompt.
- Keep fixtures free of secrets, customer data, and sensitive personal data.
- Add a local eval command such as `npm run evals` or document the exact command to run.

Finish with:
- Files changed
- Eval commands run
- Passing and failing cases
- What the suite protects against
在 ChatGPT 中尝试

介绍

构建或修改 AI 应用时,你需要确认它仍按预期工作。Evals 是系统化测试一组场景、在发布前发现回归的方法。

你可以用 Promptfoo 运行 AI 应用 evals,并让 Codex 帮你创建和维护这些 evals。

如何使用

用 Promptfoo 插件的 `$promptfoo-evals` skill,把一个 AI app 行为转成可重复 eval suite。如果应用还没有可工作的 Promptfoo target,先用 `$promptfoo-provider-setup` 把 suite 连接到用户实际访问的应用路径。

Codex 可以检查应用、提出高信号 cases、添加 Promptfoo config 和测试数据、本地运行 suite,并给出可持续使用的命令。

这个场景最适合具体行为:客服回答质量、retrieval grounding、classifier labels、tool calls、JSON shape、business rules,或 prompt/model migration confidence。

选择评估什么

从一个用户可见承诺开始。不要要求 Codex 一次评估整个 AI 系统;较小的 suite 更容易信任、审核和持续运行。

案例来源可以是产品要求、bug 报告、support escalations,或团队愿意提交到 repo 的脱敏示例。

  • Correctness:分类、抽取、总结、路由或转换。
  • Grounding:回答应该绑定到检索文档或引用来源。
  • Tool use:选择正确工具、传入合法参数、处理工具错误。
  • Format or business rules:JSON schema、字段名、业务限制或 UI-facing copy contract。
  • Prompt or model migration:确保新 prompt、model、system message 或 retrieval 设置不破坏关键场景。

先要求 eval plan

Codex 应该先检查再编辑。要求它先给出 plan,命名 target path、fixtures、assertions、adapter 和 commands。这样你能在文件创建前发现错误 target 或弱测试。

计划应说明 Promptfoo 会调用哪个应用路径或 endpoint、第一批 seed cases、assertions、Codex 会创建哪些文件、本地命令,以及需要哪些 secrets 或服务。

实现、运行和迭代

计划正确后,再让 Codex 实现。第一版应该朴素:config、cases、fixtures、必要 target adapter、命令,以及命令确实跑过的证据。

在改变行为前先运行 suite。baseline 会告诉你应用是否已经失败、assertions 是否过脆或过宽、target adapter 是否连错。

第一轮跑通后,把 suite 用于发布前比较。每当 bug、launch requirement 或 product review 暴露需要保持稳定的行为,就新增 case;本地命令稳定后,再考虑让 Codex 加到 CI 或 release checklist。

evals/
  promptfooconfig.yaml
  tests/
    cases.yaml
  providers/
    provider.js  # only if the built-in provider cannot call the app directly