symfony/ai-ollama-platform
Symfony AI bridge for the Ollama platform. Connect Symfony AI to Ollama’s chat and embedding APIs, including NDJSON streaming, using Ollama models and Modelfile capabilities. Links to docs, issues, and contributions in the main Symfony AI repo.
HttpClient, Messenger, AI traits) must be abstracted or replaced with Laravel equivalents (e.g., Http facade, Queues, custom interfaces). The Provider abstraction (v0.8.0) and model routing are valuable but need Laravel-specific implementations (e.g., service containers, interfaces).gemma:2b) are unique selling points for Laravel apps requiring multimodal AI.Messenger, AI traits) would need replacement or abstraction. The package’s dependency on Symfony’s HttpClient is the biggest hurdle; Laravel’s Http facade or Guzzle can substitute with minimal effort.symfony/ai support → Custom facades/services required.Messenger → Laravel Queues/Horizon for async tasks.HttpClient → Laravel’s Http facade or Guzzle.DeltaInterface → Custom Laravel event listeners for streaming.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony Abstraction Leakage | High | Isolate Symfony dependencies behind Laravel interfaces (e.g., OllamaClientInterface). Use adapters (e.g., HttpClientAdapter for Laravel’s Http). |
| Streaming in Laravel | High | Test NDJSON streaming with Laravel’s event system (e.g., broadcasting with Pusher, custom event listeners, or Swoole). Use queues for async streaming. |
| Ollama Infrastructure | Medium | Use Docker/Kubernetes for Ollama; implement health checks and retries in Laravel. Cache models in Laravel’s cache/database. |
| PHP Version Lock | Medium | Use php:8.1 in Docker or upgrade Laravel to 9+. Test with Laravel Pint and PHPStan for compatibility. |
| Model Catalog Management | Low | Cache models in Laravel’s cache or database. Implement a Laravel command to sync models with Ollama. |
| Structured Outputs | Low | Validate JSON/array outputs with Laravel’s validation rules or custom pipes. |
| Audio/Multimodal Support | Medium | Test gemma:2b or other audio models in a staging environment before production. |
AI component in Laravel (high effort) or use this package only for HTTP calls (lower effort)?olliwood/ollama-php) be simpler than this Symfony bridge?AI stack stable enough for production? What’s the deprecation policy for this package?olliwood/ollama-php) or Laravel-specific AI packages (e.g., beberlei/ai)?gemma:2b).HttpClient with Laravel’s Http facade or Guzzle.use Symfony\Component\AI\Ollama\OllamaClient;
use Illuminate\Support\Facades\Http;
class OllamaService {
public function __construct() {
$this->client = new OllamaClient(
Http::macro('createClient', fn() => Http::client())
);
}
public function chat(string $model, string $prompt) {
return $this->client->chat($model, $prompt);
}
}
ProviderInterface to route models dynamically.interface OllamaModelProvider {
public function getModel(string $name): string;
}
class LaravelOllamaProvider implements OllamaModelProvider {
public function getModel(string $name) {
return config("ollama.models.{$name}");
}
}
AI component in Laravel (e.g., custom AIServiceProvider, interfaces).HttpClient with Laravel’s Http facade.chat, embeddings).How can I help you explore Laravel packages today?