symfony/ai-mistral-platform
Symfony AI bridge for the Mistral platform. Integrates Mistral’s API (including chat completions) into Symfony AI, enabling easy use of Mistral models in Symfony applications with standard client abstractions and tooling.
ClientInterface and Provider.AiEventDispatcher) can be extended to integrate with Laravel’s event system (e.g., Illuminate\Events\Dispatcher), enabling observability, logging, and analytics without reinventing the wheel.DeltaInterface for semantic streaming responses is compatible with Laravel’s queue system or event loop, though additional setup may be required for real-time processing.DeltaInterface, ClientInterface), making it adaptable to Laravel’s ecosystem. This reduces boilerplate and leverages existing Laravel components like facades, service providers, and HTTP clients.EmbeddingClient) eliminates the need for custom API wrappers, accelerating development.DeltaInterface) may need Laravel-specific queue handlers or event listeners for real-time processing.Provider abstraction supports dynamic routing, but fallback logic must be explicitly implemented.DeltaInterface streams? Options include real-time UI updates (e.g., Laravel Echo) or queued jobs for async processing.AiEventDispatcher be extended to integrate with Laravel’s logging (Monolog) or monitoring (Sentry, Datadog)?Provider abstraction.Http facade or Guzzle can inject the Symfony HTTP client, enabling seamless API calls.$this->app->bind(\Symfony\Contracts\HttpClient\HttpClientInterface::class, function ($app) {
return \Symfony\Contracts\HttpClient\HttpClient::create();
});
MistralClient as a Laravel service binding:
$this->app->bind(\Symfony\Ai\Mistral\MistralClient::class, function ($app) {
return new \Symfony\Ai\Mistral\MistralClient(
$app->make(\Symfony\Contracts\HttpClient\HttpClientInterface::class)
);
});
AiEventDispatcher to dispatch Laravel events (e.g., MistralApiCalled) for observability:
$dispatcher = new AiEventDispatcher();
$dispatcher->addListener(MistralApiCalled::class, function ($event) {
event(new \App\Events\MistralApiCalled($event->getResponse()));
});
DeltaInterface) asynchronously. Store chunks in a database table and stream via Laravel Echo or Pusher.class ProcessMistralStream implements ShouldQueue
{
public function handle(DeltaInterface $delta) {
// Process and store delta chunks
}
}
$embeddings = Cache::remember("mistral_embeddings_{$input}", now()->addHours(1), function () {
return $mistralClient->embeddings()->get($input);
});
ChatClient).EmbeddingClient).class MistralServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind(\Symfony\Ai\Mistral\MistralClient::class, function ($app) {
return new \Symfony\Ai\Mistral\MistralClient($app->make(\Symfony\Contracts\HttpClient\HttpClientInterface::class));
});
}
}
Facade::register('Mistral', \App\Facades\MistralFacade::class);
// Usage: Mistral::chat()->complete($prompt);
$provider = new MultiProvider([
new MistralProvider(),
new OpenAiProvider(),
]);
spatie/laravel-queue-retries).mistral_stream_chunks)..env or vaults.| Step | Task | Dependencies |
|---|---|---|
| 1 | Add Symfony HTTP Client to composer.json |
None |
| 2 | Register MistralClient in Laravel’s service container |
Symfony HTTP |
How can I help you explore Laravel packages today?