PHP code example of vizra / evals

1. Go to this page and download the library: Download vizra/evals library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vizra / evals example snippets


// tests/Evals/SupportBotTest.php

use App\Agents\SupportBot;

it('answers support questions from documented policy', function () {
    expect(SupportBot::class)->toPassEval(fn ($eval) => $eval
        ->dataset(base_path('evals/support.jsonl'))
        ->samples(3)
        ->assert(fn ($a, $row) => $a
            ->notEmpty()->gate()
            ->contains($row->expected())
            ->costBelow(0.02))
        ->judge('Answers using only documented store policy.', min: 7)
        ->gate(minScore: 0.8, maxRegressions: 0)
    );
});

Schedule::command('evals:sync-pricing')->weekly();

Schedule::command('evals:runner')->everyMinute()->withoutOverlapping();
bash
php artisan evals:calibrate storage/labelled.jsonl --criteria="Correctness"
bash
php artisan evals:sync-pricing        # writes config/evals-pricing.php