symfony/ai-albert-platform
Symfony AI bridge for the French government’s Albert Platform (OpenGateLLM). Connect Symfony apps to Albert’s OpenAI-compatible chat and embeddings endpoints, with links to the API reference, supported models, and upstream sources.
symfony/http-client, symfony/options-resolver). This reduces friction for teams already using Symfony’s AI stack or planning to adopt it.openai/php-sdk or similar packages to this bridge is low-effort, with minimal code changes required.Guzzle or Symfony HTTP Client can handle API calls, though the package abstracts this layer. No additional HTTP client is required beyond what Symfony AI provides.bus:dispatch) or events can process AI responses asynchronously, reducing latency in user-facing requests.Illuminate\Support\Facades\Cache) can cache embeddings or frequent API responses to optimize performance.symfony/ai, which may introduce version constraints (e.g., PHP 8.1+). Laravel apps must ensure compatibility with Symfony’s versioning.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Vendor Lock-in | Albert is a niche provider; dependency on Etalab’s API could introduce risk if the platform changes. | Leverage the Provider abstraction to support fallback providers (e.g., OpenAI, Hugging Face) dynamically. |
| API Changes | Albert’s API may evolve, and backward compatibility isn’t guaranteed. | Monitor OpenGateLLM docs and implement retries/circuit breakers (e.g., Laravel’s Spatie/Fluent). |
| Performance | Latency may differ from OpenAI; embedding performance could vary significantly. | Benchmark against OpenAI and implement caching (e.g., Redis) for frequent queries. Use Laravel’s queue for async calls. |
| Cost | Albert’s pricing model may differ from OpenAI (e.g., EU subsidies, token costs). | Audit usage via Laravel logging and compare total cost of ownership (TCO) with OpenAI. |
| Documentation | Limited stars/release history suggests low community adoption; documentation may be sparse. | Rely on Symfony AI docs and cross-reference with OpenGateLLM compatibility tables. |
| Embedding Limitations | Embeddings may not support all use cases (e.g., real-time streaming, fine-tuning). | Test embeddings with downstream tools (e.g., Meilisearch, Weaviate) early and validate performance. |
Provider abstraction be configured?too_many_requests errors)?mistral-7b for cost efficiency or llama-2 for quality)? If so, how will this be configured?Sentry, Laravel Debugbar, or custom metrics.)Http::fake() or a local provider stub.)| Laravel Component | Integration Strategy |
|---|---|
| Service Container | Register the Albert provider as a bindable service in Laravel’s container. Use interface-based dependency injection to support multiple providers (e.g., AiProviderInterface). Example: |
| ```php | |
| // config/ai.php | |
| 'providers' => [ | |
| 'albert' => [ | |
| 'api_key' => env('ALBERT_API_KEY'), | |
| 'base_uri' => 'https://albert.api.etalab.gouv.fr', | |
| 'fallback' => 'openai', // Optional fallback provider | |
| ], | |
| ], | |
| ``` | |
| HTTP Client | Use Laravel’s built-in Http facade or symfony/http-client (included via Symfony AI). No additional setup is required beyond configuring the provider. |
| Queues | Offload AI calls to Laravel’s queue system (e.g., bus:dispatch) to avoid blocking HTTP requests. Use job classes to process AI responses asynchronously. Example: |
| ```php | |
| php artisan make:job ProcessAlbertAiResponse | |
| ``` | |
| Events | Trigger events (e.g., AiResponseGenerated) for post-processing (e.g., logging, analytics, or downstream actions). Use Laravel’s event system to decouple AI responses from business logic. |
| Caching | Cache embeddings or frequent API responses using Laravel’s caching mechanisms (e.g., Illuminate\Support\Facades\Cache). Example: |
| ```php | |
| $embedding = Cache::remember("embedding_{$documentId}", now()->addHours(1), function () use ($documentId) { | |
| return $this->albert->embed([...]); | |
| }); | |
| Testing | Mock Albert’s API using Laravel’s Http::fake() or create a local provider stub for unit/integration tests. Example: |
| ```php | |
| Http::fake([ | |
| 'albert.api.etalab.gouv.fr' => Http::response([...], 200), | |
| ]); | |
| ``` |
choices, usage, data fields).How can I help you explore Laravel packages today?