adachsoft / ai-evaluation-jev-ai
A Jev AI adapter for evaluating descriptions against typed evaluation rules.
Requires
- php: >=8.2
- adachsoft/ai-evaluation-contracts: ^0.1
- adachsoft/collection: ^3.0
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- adachsoft/php-code-style: ^0.7.1
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.7
- symplify/phpstan-rules: ^14.19
- vlucas/phpdotenv: ^5.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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.