- How do I connect Laravel to the Albert Platform using this package?
- Register the `AlbertProvider` in your `AppServiceProvider` and bind it to `AiClientInterface`. Use Laravel’s Guzzle HTTP client (default) or Symfony’s HTTP client. Configure retries and timeouts in `config/ai.php`. The package abstracts API calls to match OpenAI’s SDK structure.
- Does this package support Laravel queues for async AI processing?
- Yes. Dispatch AI tasks (e.g., embeddings or chat completions) to Laravel queues using `AiClient::create()->queue()`. Ideal for bulk operations or long-running tasks. Configure the queue in `config/ai.php` and use `bus:dispatch` in your code.
- Can I cache AI responses or embeddings in Laravel?
- Absolutely. Use Laravel’s cache drivers (Redis, database) to store embeddings or frequent API responses. Example: Cache embeddings for a document with `Cache::remember()` and the `AiClient` to avoid redundant API calls.
- What Laravel versions and PHP versions are supported?
- This package follows Symfony AI’s compatibility. Check the [Symfony AI docs](https://symfony.com/doc/current/ai.html) for the latest Laravel (8.83+ recommended) and PHP (8.1+) support. The Albert Platform itself requires PHP 8.1+.
- How do I handle API failures or rate limits with Albert?
- Configure retries in `config/ai.php` (e.g., `max_retries: 3`). The package supports fallback to OpenAI via `OpenAiProvider` if Albert fails. Use Laravel’s exception handling to log errors or trigger alerts.
- Are there alternatives to this package for Albert integration?
- The official Symfony AI package (`symfony/ai`) is the primary bridge, but you could also use the raw [Albert API client](https://github.com/etalab-ia/OpenGateLLM) or a custom wrapper. However, Symfony AI provides OpenAI compatibility, queues, and Laravel integration out of the box.
- How do I test AI responses in Laravel’s testing environment?
- Mock Albert’s API using Laravel’s `Http::fake()` or Symfony’s `HttpClientMock`. Example: Fake responses for `albert.api.etalab.gouv.fr` and assert AI client behavior. This works seamlessly with Laravel’s HTTP testing helpers.
- Can I store AI-generated embeddings or responses in a database?
- Yes. Use Eloquent models to store embeddings (as arrays) or AI responses. Example: Define a `AiResponse` model with `content` and `embedding` fields cast to arrays. Sync responses via events or observers.
- What models does Albert support, and how do I switch between them?
- Albert supports OpenAI-compatible models like `mistral-7b` or `llama-2`. Specify the model in your API call (e.g., `->withModel('mistral-7b')`). Check [Albert’s docs](https://docs.opengatellm.org/features/supported_models/) for full compatibility.
- How do I integrate AI responses into Blade templates or Inertia.js?
- Pass AI responses to Blade via controllers or directly render them in templates. For Inertia.js, return responses as JSON and use Vue/React to display dynamic content. Example: Loop through `$chatbotResponses` in Blade or pass them to Inertia props.