Add complete Laravel LLM Gateway implementation
Core Features: - Multi-provider support (OpenAI, Anthropic, DeepSeek, Gemini, Mistral) - Provider service architecture with abstract base class - Dynamic model discovery from provider APIs - Encrypted per-user provider credentials storage Admin Interface: - Complete admin panel with Livewire components - User management with CRUD operations - API key management with testing capabilities - Budget system with limits and reset schedules - Usage logs with filtering and CSV export - Model pricing management with cost calculator - Dashboard with Chart.js visualizations Database Schema: - MariaDB migrations for all tables - User provider credentials (encrypted) - LLM request logging - Budget tracking and rate limiting - Model pricing configuration API Implementation: - OpenAI-compatible endpoints - Budget checking middleware - Rate limit enforcement - Request logging jobs - Cost calculation service Testing: - Unit tests for all provider services - Provider factory tests - Cost calculator tests Documentation: - Admin user seeder - Model pricing seeder - Configuration files
This commit is contained in:
52
laravel-app/app/Jobs/ResetMonthlyBudgets.php
Normal file
52
laravel-app/app/Jobs/ResetMonthlyBudgets.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\UserBudget;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ResetMonthlyBudgets implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$now = now();
|
||||
$thisMonth = $now->startOfMonth();
|
||||
|
||||
// Find all budgets that need monthly reset
|
||||
$budgets = UserBudget::where('month_started_at', '<', $thisMonth)
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$resetCount = 0;
|
||||
|
||||
foreach ($budgets as $budget) {
|
||||
$budget->current_month_spending = 0.0;
|
||||
$budget->month_started_at = $thisMonth;
|
||||
$budget->is_budget_exceeded = false;
|
||||
$budget->last_alert_sent_at = null;
|
||||
$budget->save();
|
||||
|
||||
$resetCount++;
|
||||
|
||||
Log::info('Monthly budget reset for user', [
|
||||
'user_id' => $budget->user_id,
|
||||
'previous_spending' => $budget->current_month_spending
|
||||
]);
|
||||
}
|
||||
|
||||
Log::info('Monthly budgets reset', [
|
||||
'count' => $resetCount,
|
||||
'month' => $thisMonth->format('Y-m')
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user