Skip to content

Judge with structured evaluations and add a classification judge - #7

Merged
pushpak1300 merged 2 commits into
1.x-supportfrom
1.x-classifier-support
Sep 23, 2026
Merged

pushpak1300 merged 2 commits into
1.x-supportfrom
1.x-classifier-support

Conversation

@pushpak1300

@pushpak1300 pushpak1300 commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Classification models such as TypeSafe's JEV are faster and cheaper than text models for grading. This lets them be the judge. Scorers now describe their evaluation as data, so each judge gets a request in its own format.

Usage

Add the provider key to .env:

TYPESAFE_API_KEY=...

Turn on the classifier judge in tests/Pest.php:

pest()->evals()->classify();                                          // ai.default_for_classification
pest()->evals()->classify(provider: 'typesafe', model: 'jev-latest'); // or pick one

Write evals as before. toSatisfy(), toBeCorrect(), toBeRelevant() and toBeSafe() use the classifier:

it('answers refund questions', function () {
    expect(RefundPolicyAgent::class)
        ->prompt('Can I get a refund on my purchase from two weeks ago?')
        ->toBeRelevant()
        ->toSatisfy('States the 30-day refund window.');
});

Run with vendor/bin/pest --evals. PEST_EVALS_LARAVEL_CLASSIFICATION_PROVIDER and PEST_EVALS_LARAVEL_CLASSIFICATION_MODEL override the provider and model per environment.

Note

Only one judge is active. classify() is shorthand for judgeUsing(new LaravelAiClassifier(...)), so a later judgeUsing() replaces it.

Warning

Upgrade note: JudgeDriver::generate() becomes judge(Evaluation $evaluation): Verdict. judgeUsing() closures receive an Evaluation and return a float or a Verdict. Custom judged scorers use Judge::evaluate() because JudgeResponse is removed.

@pushpak1300
pushpak1300 added this pull request to stack #8 September 23, 2026 09:37
@pushpak1300 pushpak1300 mentioned this pull request Sep 23, 2026
@pushpak1300 pushpak1300 changed the title Judge scorers with structured levels and add a classification judge Judge with structured evaluations and add a classification judge Sep 23, 2026
@pushpak1300
pushpak1300 merged commit 98a4f7b into 5.x Sep 23, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant