PHP code example of mubseoul / laravel-llm-observability
1. Go to this page and download the library: Download mubseoul/laravel-llm-observability 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/ */
mubseoul / laravel-llm-observability example snippets
use Mubseoul\LLMObservability\Services\QuotaEnforcer;
$enforcer = app(QuotaEnforcer::class);
$result = $enforcer->checkQuota(
userId: auth()->id(),
estimatedTokens: 1000,
estimatedCost: 0.05
);
if (!$result['allowed']) {
throw new Exception($result['reason']);
}
use Mubseoul\LLMObservability\Models\LLMQuota;
// Create a custom quota for a user
LLMQuota::create([
'scope' => 'user',
'scope_id' => '123',
'requests_per_day' => 500,
'cost_per_month' => 50.00,
'enabled' => true,
]);
// Get or create quota with defaults
$quota = app(QuotaEnforcer::class)->getOrCreateQuota('user', '123');
bash
# Recalculate last 90 days
php artisan llm:recalc-aggregates
# Custom date range
php artisan llm:recalc-aggregates --from=2024-01-01 --to=2024-12-31
bash
composer analyse
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.