Skip to content

التقييم في CI

شغّل تقييمات Potato داخل حزمة pytest الخاصة بك واجعل CI مشروطًا بعتبات الدرجات، حتى يُفشل أي تغيير في الموجّه أو النموذج يتراجع بجودة الوكيل عمليةَ البناء كما يفعل اختبار الوحدة. يتضمن واجهة تأكيدات expect() ومثالًا لسير عمل GitHub Actions.

شغّل تقييمات Potato داخل حزمة pytest الخاصة بك واجعل CI مشروطًا بعتبات الدرجات المجمَّعة، حتى يُفشل تغييرٌ في الموجّه أو النموذج يتراجع بالجودة عمليةَ البناء تمامًا كما يفعل اختبار الوحدة. هذه هي طبقة «التشغيل العملي للتقييم» فوق المُقيِّمات البرمجية ومجموعات البيانات والتجارب.

التثبيت

يأتي المكوّن الإضافي مع Potato ويُحمَّل تلقائيًا بعد التثبيت:

bash
pip install -e .          # registers the `potato_eval` pytest plugin

من دون تثبيت، حمِّله صراحةً: pytest -p potato.testing.pytest_plugin.

كتابة اختبارات التقييم

ضع على الاختبار الوسم @pytest.mark.potato_eval واطلب الـ fixture المسمى potato_eval:

python
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 assertion

توفّر expect(...) الدوال .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 (متوسط لكل مفتاح) عبر جميع اختبارات التقييم.

اشتراط البناء

bash
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) يمكنك رفعها كأثر (artifact) في CI.

GitHub Actions

يوجد مثال لسير عمل في examples/agent-traces/ci-eval/ci_workflow_example.yml. يشغّل الحزمة على كل طلب سحب، ويشترط العتبات، ويرفع سجلات التجارب كأثر.

مواضيع ذات صلة