Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ai Ollama Platform Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Local AI Adoption: Enables self-hosted LLM workflows in Symfony/Laravel apps, reducing dependency on cloud providers (e.g., OpenAI) for cost, latency, or compliance reasons. Aligns with trends toward on-premise AI and edge computing.
  • AI-First Roadmap: Accelerates delivery of AI-powered features (e.g., chatbots, embeddings, structured data extraction) without building low-level API wrappers. Supports Symfony AI ecosystem integration for future scalability.
  • Build vs. Buy: Buy—avoids reinventing Ollama API clients, authentication, streaming, and model routing. Leverages Symfony’s maintained ecosystem (MIT license) for long-term reliability.
  • Use Cases:
    • Real-Time Chat/Assistants: Streaming NDJSON responses for conversational UIs (e.g., customer support, internal tools).
    • Embeddings & Search: Local vector databases (e.g., Qdrant, Weaviate) paired with Ollama models for hybrid search (e.g., document retrieval).
    • Structured Outputs: Parse LLM responses into JSON/arrays for workflow automation (e.g., data extraction, form filling).
    • Multimodal AI: Audio capabilities (e.g., gemma:2b) for voice-to-text, transcription, or multimodal prompts.
    • Offline/Edge AI: Deploy models locally for low-latency or air-gapped systems (e.g., healthcare, defense, IoT).
    • Cost Optimization: Replace cloud API calls (e.g., OpenAI) with local inference for high-volume internal tools (e.g., batch processing, data labeling).
  • Tech Stack Alignment:
    • Symfony: Native integration with symfony/ai; minimal glue code for chat/embeddings.
    • Laravel: Requires adapters (e.g., wrapping Symfony’s HttpClient) but enables reuse of Ollama’s capabilities.
  • Compliance & Security:
    • Data Sovereignty: Process sensitive data locally (e.g., GDPR, HIPAA) without cloud exposure.
    • Vendor Lock-In Avoidance: Use open-source models (e.g., Llama, Mistral) via Ollama, not proprietary APIs.

When to Consider This Package

Adopt if:

  • Your Symfony/Laravel app needs Ollama integration with minimal boilerplate (chat, embeddings, streaming).
  • You prioritize local AI for cost, latency, or compliance (e.g., GDPR, edge devices).
  • Your use case requires structured outputs (JSON/arrays) or audio capabilities (e.g., gemma:2b).
  • You’re using Symfony AI or want to align with Symfony’s ecosystem (long-term maintainability).
  • Your team can manage Ollama infrastructure (Docker, model updates, scaling).
  • You need real-time streaming (NDJSON/SSE) for chat interfaces or incremental processing.

Look elsewhere if:

  • You require cloud-scale AI (e.g., OpenAI, Anthropic) or managed services (e.g., AWS Bedrock).
  • Your use case demands custom model training/fine-tuning (Ollama supports inference only; use Hugging Face or vLLM for training).
  • You’re not using Symfony/Laravel (though PHP-agnostic, Symfony integration adds value).
  • Your team lacks PHP 8.1+ or Symfony/Laravel expertise (though the API is straightforward).
  • You need GPU acceleration beyond Ollama’s native support (e.g., vLLM, TensorRT-LLM).
  • Ollama infrastructure is prohibitive (e.g., no Docker, limited hardware for large models).

How to Pitch It (Stakeholders)

For Executives: *"This package lets us deploy AI locally using Ollama, cutting cloud API costs and improving latency for internal tools. Key wins:

  • Cost Savings: Replace OpenAI calls (e.g., $0.002/1K tokens) with free local inference for high-volume use cases (e.g., batch processing, data labeling).
  • Compliance: Process sensitive data on-premise (e.g., healthcare, finance) without cloud exposure.
  • Speed: Sub-100ms responses for edge devices or air-gapped systems (e.g., defense, IoT).
  • Future-Proof: Aligns with Symfony’s AI ecosystem, avoiding vendor lock-in. Example: Launch a local chatbot for customer support or a document search assistant using Ollama’s llama3 model—in weeks, not months—with real-time streaming responses. Risk: Requires Ollama server setup (Docker/managed service), but payback is immediate for cost-sensitive or latency-critical use cases."*

For Engineering: *"This is a production-ready Ollama client for Symfony/Laravel, handling:

  • Authentication: Seamless integration with Symfony’s HttpClient (or Laravel’s Http facade with adapters).
  • Streaming: NDJSON/SSE support for real-time chat UIs (no manual chunk parsing).
  • Model Routing: Dynamic model selection (e.g., route gemma:2b for audio tasks via Provider abstraction).
  • Structured Outputs: Parse LLM responses into JSON/arrays for programmatic use (e.g., workflows).
  • Audio/Multimodal: Use models like gemma:2b for voice-to-text or audio analysis. Why not build?
  • Maintenance: Symfony’s team handles updates (e.g., streaming bug fixes in v0.7.0).
  • Testing: Battle-tested with Symfony AI; Laravel integration is low-risk with adapters.
  • Speed: Focus on your app logic—no HTTP clients, NDJSON parsing, or auth to write. Use it for:
  • Chatbots, embeddings, or any use case where you’d call Ollama’s API directly.
  • Laravel Workaround: Wrap Symfony’s OllamaClient in a service using Laravel’s Http facade (see example below).
// Laravel Service Example
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);
    }
}

Caveats:

  • Requires Ollama server (Docker setup recommended).
  • Symfony abstractions (e.g., Provider) need Laravel adapters for full feature parity.
  • Test streaming with Laravel’s event loop (e.g., Pusher, Swoole)."*

For Data/ML Teams: *"This package enables local LLM inference for:

  • Embeddings: Generate vectors with Ollama models (e.g., nomic-embed-text) for vector search (e.g., Qdrant, Weaviate).
  • Hybrid Search: Combine Ollama embeddings with traditional search (e.g., Elasticsearch) for semantic retrieval.
  • Structured Data Extraction: Use structured_output (v0.7.0) to parse LLM responses into JSON/arrays for ML pipelines. Example: Deploy a local RAG system (Retrieval-Augmented Generation) with Ollama + a vector DB, avoiding cloud API costs. Limitations:
  • No fine-tuning (use Hugging Face for training).
  • Model performance depends on Ollama’s hardware (e.g., GPU for large models like llama3)."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony