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:
wtrinkl
2025-11-18 22:18:36 +01:00
parent bef36c7ca2
commit 6573e15ba4
60 changed files with 5991 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Budget Settings
|--------------------------------------------------------------------------
|
| These values are used when creating new user budgets
|
*/
'default_monthly_budget' => env('LLM_DEFAULT_MONTHLY_BUDGET', 100.00),
'default_daily_budget' => env('LLM_DEFAULT_DAILY_BUDGET', 10.00),
/*
|--------------------------------------------------------------------------
| Rate Limiting Settings
|--------------------------------------------------------------------------
|
| Default rate limits for API requests per user
|
*/
'rate_limit' => [
'requests_per_minute' => env('LLM_RATE_LIMIT_PER_MINUTE', 60),
'requests_per_hour' => env('LLM_RATE_LIMIT_PER_HOUR', 1000),
'requests_per_day' => env('LLM_RATE_LIMIT_PER_DAY', 10000),
],
/*
|--------------------------------------------------------------------------
| Supported Providers
|--------------------------------------------------------------------------
|
| List of AI providers supported by the gateway
|
*/
'providers' => [
'openai' => [
'name' => 'OpenAI',
'api_url' => 'https://api.openai.com/v1',
'models' => ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo', 'gpt-3.5-turbo'],
],
'anthropic' => [
'name' => 'Anthropic (Claude)',
'api_url' => 'https://api.anthropic.com/v1',
'models' => ['claude-opus-4', 'claude-sonnet-4', 'claude-haiku-4'],
],
'mistral' => [
'name' => 'Mistral AI',
'api_url' => 'https://api.mistral.ai/v1',
'models' => ['mistral-large', 'mistral-medium', 'mistral-small'],
],
'gemini' => [
'name' => 'Google Gemini',
'api_url' => 'https://generativelanguage.googleapis.com/v1beta',
'models' => ['gemini-pro', 'gemini-pro-vision'],
],
'deepseek' => [
'name' => 'DeepSeek',
'api_url' => 'https://api.deepseek.com/v1',
'models' => ['deepseek-chat', 'deepseek-coder'],
],
],
/*
|--------------------------------------------------------------------------
| Logging Settings
|--------------------------------------------------------------------------
|
| Configuration for request logging
|
*/
'logging' => [
'enabled' => env('LLM_LOGGING_ENABLED', true),
'queue' => env('LLM_LOGGING_QUEUE', true),
],
/*
|--------------------------------------------------------------------------
| Alert Settings
|--------------------------------------------------------------------------
|
| Budget alert threshold and notification settings
|
*/
'alerts' => [
'budget_threshold_percentage' => env('LLM_ALERT_THRESHOLD', 80),
'email_enabled' => env('LLM_ALERT_EMAIL_ENABLED', true),
],
];