1. Go to this page and download the library: Download maeandrew/laya-laravel 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/ */
maeandrew / laya-laravel example snippets
use Laravel\Ai\Classification;
use Laravel\Ai\Classification\Boolean;
use Laravel\Ai\Classification\Choice;
use Laravel\Ai\Classification\Score;
$result = Classification::of([
'subject' => 'Duplicate charge',
'body' => 'I was charged twice. Please refund the duplicate today.',
])->questions([
'urgent' => new Boolean('Does this request need an immediate response?', [
'true' => 'Explicitly time-sensitive',
'false' => 'No deadline is expressed',
]),
'department' => new Choice('Which team should handle this request?', [
'billing' => 'Payments, invoices, and refunds',
'technical' => 'Bugs and outages',
'sales' => 'Pricing and upgrades',
]),
'frustration' => new Score('How frustrated is the customer?', [
'Calm',
'Frustrated',
'Very angry',
]),
])->classify('laya');
$result['department']->choice; // "billing"
$result['department']->confidence; // calibrated confidence
$result['urgent']->isTrue(0.8); // apply your own action threshold
$result['frustration']->label(); // most probable level label
$result->meta->model; // "laya-rl-agent"
Classification::fake();
$result = Classification::of('A test ticket.')
->question('urgent', new Boolean('Is this urgent?'))
->classify('laya');
Classification::assertClassified(fn ($prompt) => $prompt->provider->name() === 'laya');
bash
php artisan vendor:publish --tag=laya-config
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.