Search by

adachsoft / ai-evaluation-jev-ai

Arkadiusz Adach

A Jev AI adapter for evaluating descriptions against typed evaluation rules.

Package info

gitlab.com/a.adach/ai-evaluation-jev-ai

Issues

pkg:composer/adachsoft/ai-evaluation-jev-ai

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-10-21 11:39 UTC

This package is not auto-updated.

Last update: 2026-10-22 08:22:41 UTC


README

AI Evaluation Jev AI is an adapter for evaluating descriptions against typed evaluation rules through the Jev AI API. It implements the contracts provided by adachsoft/ai-evaluation-contracts and maps provider responses to the shared evaluation result objects.

Features

  • Boolean, choice, and scale evaluation rules.
  • Consistent result and exception types from the shared evaluation contracts.
  • Configurable Jev AI model, base URL, timeout, and retry policy.
  • Transport isolation for deterministic unit testing.

Requirements

  • PHP 8.2 or newer.
  • A Jev AI API key.

Installation

composer require adachsoft/ai-evaluation-jev-ai

Configuration

Keep the API key outside source control and provide it through the application environment:

JEV_AI_API_KEY=your-api-key
JEV_AI_BASE_URL=https://api.typesafe.ai

The base URL is optional. The library uses https://api.typesafe.ai by default.

Usage

<?php

declare(strict_types=1);

use AdachSoft\AiEvaluationContracts\Collection\RuleCollection;
use AdachSoft\AiEvaluationContracts\Dto\EvaluationRequestDto;
use AdachSoft\AiEvaluationContracts\Rule\BooleanRuleDto;
use AdachSoft\AiEvaluationJevAi\Config\JevAiConfigDto;
use AdachSoft\AiEvaluationJevAi\JevAiEvaluatorFactory;

$apiKey = getenv('JEV_AI_API_KEY');

if ($apiKey === false || trim($apiKey) === '') {
    throw new RuntimeException('JEV_AI_API_KEY is required.');
}

$config = new JevAiConfigDto(
    apiKey: trim($apiKey),
    baseUrl: getenv('JEV_AI_BASE_URL') ?: 'https://api.typesafe.ai',
);

$evaluator = JevAiEvaluatorFactory::create($config->apiKey, $config);
$result = $evaluator->evaluate(
    new EvaluationRequestDto(
        'The support response solved the customer problem.',
        new RuleCollection([
            'solved' => new BooleanRuleDto('Did the response solve the customer problem?'),
        ]),
    ),
);

$verdict = $result->verdicts->get('solved');

The evaluator accepts up to eight rules in one request. Authentication, rate limiting, provider availability, invalid requests, and invalid responses are reported through the shared contract exceptions.

Examples

See docs/examples/basic-usage.md for a complete integration example.

License

This library is released under the MIT License.