borah/llm-monitoring-laravel
Composer 安装命令:
composer require borah/llm-monitoring-laravel
包简介
Advanced LLM monitoring using LLM Port and Filament panel
README 文档
README
A comprehensive monitoring solution for Large Language Model usage in Laravel applications using LLM Port and Filament.
Features
- Track LLM API calls and usage statistics
- Evaluate LLM responses using built-in metrics
- Monitor token usage and costs
- Integrated Filament dashboard
- Extensible architecture for custom metrics
Installation
You can install the package via composer:
composer require borah/llm-monitoring-laravel
Then run the installation command:
php artisan llm-monitoring:install
This will:
- Publish the config file
- Run migrations to create necessary tables
- Copy the LlmPortCall model to your app
- Set up Filament resources and dashboard components
Configuration
After installation, you can configure the package in config/llm-monitoring.php:
return [ 'llmport' => [ 'driver' => null, // one of the llmport.php drivers 'model' => null, ], 'probability' => 100, // 0 to 100. Chance of a response being evaluated. 100 is always. 'evaluations' => [ \Borah\LlmMonitoring\Evaluations\AnswerRelevance::class, \Borah\LlmMonitoring\Evaluations\ContextRelevanceChainOfThought::class, ], ];
Dashboard Setup
During installation, a Filament dashboard will be set up. Make sure to register it in your Filament panel provider:
// in app/Providers/Filament/AdminPanelProvider.php public function panel(Panel $panel): Panel { return $panel // ... other configuration ->pages([ \App\Filament\Pages\LlmDashboard::class, ]) ->discoverWidgets(in: app_path('Filament/LlmMonitoring/Widgets'), for: 'App\\Filament\\LlmMonitoring\\Widgets'); }
Adding Custom Widgets
You can extend the dashboard with your own custom widgets. Create a new class that extends the LlmDashboard:
namespace App\Filament\Pages; use App\Filament\LlmMonitoring\Widgets\LlmCallsChart; use App\Filament\LlmMonitoring\Widgets\LlmStats; use App\Filament\LlmMonitoring\Widgets\LlmTokenConsumption; use App\Filament\Widgets\MyCustomWidget; class CustomLlmDashboard extends \App\Filament\Pages\LlmDashboard { public function getWidgets(): array { return [ LlmStats::class, LlmCallsChart::class, LlmTokenConsumption::class, MyCustomWidget::class, ]; } }
Then update your panel configuration to use your custom dashboard:
->pages([ \App\Filament\Pages\CustomLlmDashboard::class, ])
Creating Custom Evaluations
You can create custom evaluation metrics by extending the BaseEvaluation class:
namespace App\Evaluations; use Borah\LlmMonitoring\Evaluations\BaseEvaluation; use Borah\LlmMonitoring\ValueObjects\EvaluationData; use Borah\LlmMonitoring\ValueObjects\EvaluationResult; use Borah\LLMPort\ValueObjects\ChatResponse; class MyCustomEvaluation extends BaseEvaluation { public function identifier(): string { return 'my-custom-evaluation'; } public function description(): string { return 'Evaluates something custom about the LLM response'; } public function systemPrompt(EvaluationData $data): string { return 'You are evaluating the quality of an AI response.'; } public function userPrompt(EvaluationData $data): string { return "User Query: {$data->query}\n\nAI Response: {$data->response}"; } protected function evaluate(EvaluationData $data, mixed $response): EvaluationResult { if ($response instanceof ChatResponse) { // Process the response and return a result return new EvaluationResult( value: 0.85, formattedValue: '85%', metadata: ['details' => 'Additional evaluation details'] ); } return new EvaluationResult(value: 0, formattedValue: '0%'); } }
Then add your custom evaluation to the config:
'evaluations' => [ \Borah\LlmMonitoring\Evaluations\AnswerRelevance::class, \Borah\LlmMonitoring\Evaluations\ContextRelevanceChainOfThought::class, \App\Evaluations\MyCustomEvaluation::class, ],
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
borah/llm-monitoring-laravel 适用场景与选型建议
borah/llm-monitoring-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.26k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Borah」 「llm-monitoring-laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 borah/llm-monitoring-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 borah/llm-monitoring-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 borah/llm-monitoring-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Wrapper around the most popular LLMs that allows drop-in replacement of large language models in Laravel.
Laravel wrapper for the Knowledge-Base API
Alfabank REST API integration
Bypass CORS issues when developing locally with no hassle.
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 1.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-26