CI 評価
Potato の評価を自分の pytest スイートの中で実行し、スコアのしきい値で CI をゲートします。エージェントの品質を退行させるプロンプトやモデルの変更は、ユニット・テストと同じようにビルドを失敗させます。expect() アサーション API と GitHub Actions のワークフロー例付きです。
Potato の評価を自分の pytest スイートの中で実行し、集計スコアのしきい値で CI をゲートします。 品質を退行させるプロンプトやモデルの変更は、ユニット・テストと同じようにビルドを失敗させます。これはプログラマティック評価器とデータセットと実験の上に載る「評価の運用化」レイヤーです。
インストール
プラグインは Potato に同梱されており、インストールすれば自動的に読み込まれます。
pip install -e . # registers the `potato_eval` pytest pluginインストールしない場合は、明示的に読み込みます:pytest -p potato.testing.pytest_plugin。
評価テストを書く
テストに @pytest.mark.potato_eval を付け、potato_eval フィクスチャを要求します。
import pytest
from potato.testing import expect
@pytest.mark.potato_eval
@pytest.mark.parametrize("case", CASES, ids=[c["q"] for c in CASES])
def test_agent(case, potato_eval):
out = my_agent(case["q"])
potato_eval.log_inputs({"question": case["q"]})
potato_eval.log_outputs(out)
potato_eval.log_reference_outputs(case["expected"])
potato_eval.log_feedback("correct", 1.0 if out == case["expected"] else 0.0)
potato_eval.log_feedback("similarity", 1.0 - expect.edit_distance(out, case["expected"]).value)
expect(out).to_contain(case["expected"]) # per-case hard assertionexpect(...) は .to_equal、.to_contain、.to_be_less_than、.to_be_greater_than、.to_be_between、.to_be_close_to に加えて、expect.edit_distance(a, b) と expect.embedding_distance(a, b) を提供します。log_feedback のスコアは、すべての評価テストにわたってキーごとの平均として集計されます。
ビルドをゲートする
pytest tests/eval/ \
--potato-threshold correct=0.8 \
--potato-threshold similarity=0.7 \
--potato-experiment agent-regression| オプション | 効果 |
|---|---|
--potato-threshold KEY=MIN | mean(KEY) < MIN なら実行を失敗させます。繰り返し指定できます。 |
--potato-experiment DATASET | 実行を実験として記録します。 |
--potato-no-sync | 実験の記録をスキップします。 |
しきい値に違反すると、実行は非ゼロで終了し(CI ジョブが失敗し)、THRESHOLD FAILED: <key> = <actual> < <min> を出力します。記録された実験はプレーンなファイル($POTATO_EVAL_STORE、デフォルトは ./eval_store)なので、CI のアーティファクトとしてアップロードできます。
GitHub Actions
ワークフローの例は examples/agent-traces/ci-eval/ci_workflow_example.yml にあります。すべての PR でスイートを実行し、しきい値でゲートし、実験の記録をアーティファクトとしてアップロードします。
関連項目
- Read the Docs の完全なリファレンス — すべての pytest オプションと環境変数、バージョン対応版
- プログラマティック評価器
- データセットと実験