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 abstractions without major refactoring.AiEventDispatcher can be bridged to Laravel’s event system (e.g., Illuminate\Events\Dispatcher), enabling centralized logging, monitoring, and analytics. This avoids reinventing observability layers.DeltaInterface for semantic streaming is compatible with Laravel’s queue system or event loop, though additional middleware (e.g., queue workers) may be needed for real-time processing.EmbeddingClient and ChatClient can be injected directly into Laravel services.App\Exceptions\Handler) can extend Symfony’s error traits..env) or config files (config/ai.php). Example:
// config/ai.php
'providers' => [
'mistral' => [
'client' => \Symfony\Ai\Mistral\MistralClient::class,
'api_key' => env('MISTRAL_API_KEY'),
'endpoint' => env('MISTRAL_ENDPOINT', 'https://api.mistral.ai'),
],
],
AppServiceProvider).DeltaInterface) may require custom queue handlers or event listeners for real-time processing. Laravel’s queue system may need middleware to handle chunked responses.Illuminate\Support\Facades\Cache).Provider abstraction? Will dynamic routing be implemented via Laravel’s service container or a custom middleware?DeltaInterface streams? Options include:
handleMistralStream job processing chunks).MistralBatchClient)?Illuminate\Support\Facades\Retry)?circuit-breaker)?AiEventDispatcher integrate with Laravel’s:
Illuminate\Cache)?.env)?Crypt)?Mistral::chat()) be created for cleaner syntax?// Custom queue job for streaming
class HandleMistralStream implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;
public function handle(DeltaInterface $delta) {
// Process chunk (e.g., append to response buffer)
}
}
HttpClientInterface can be injected directly. Example binding:
// app/Providers/AppServiceProvider.php
public function register()
{
$this->app->bind(\Symfony\Contracts\HttpClient\HttpClientInterface::class, function () {
return \Symfony\Contracts\HttpClient\HttpClient::create([
'base_uri' => env('MISTRAL_ENDPOINT'),
'auth_bearer' => env('MISTRAL_API_KEY'),
]);
});
}
MistralClient as a Laravel service:
$this->app->bind(\Symfony\Ai\Mistral\MistralClient::class, function ($app) {
return new \Symfony\Ai\Mistral\MistralClient(
$app->make(\Symfony\Contracts\HttpClient\HttpClientInterface::class)
);
});
$this->app->bind(\Symfony\Ai\ProviderInterface::class, function ($app) {
return new \Symfony\Ai\Provider\MistralProvider(
$app->make(\Symfony\Ai\Mistral\MistralClient::class)
);
});
AiEventDispatcher to Laravel’s events:
// app/Providers/EventServiceProvider.php
public function boot()
{
$dispatcher = new \Symfony\Ai\EventDispatcher\AiEventDispatcher();
$dispatcher->addListener(\Symfony\Ai\Event\AiEvent::class, function ($event) {
event(new \App\Events\AiEventFired($event));
});
}
// app/Jobs/ProcessMistralStream.php
public function handle(DeltaInterface $delta)
{
// Append to response buffer or update UI
cache()->forever('mistral_stream_buffer', $delta->getContent());
}
How can I help you explore Laravel packages today?