Download the PHP package camh/laravel-ollama without Composer
On this page you can find all versions of the php package camh/laravel-ollama. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download camh/laravel-ollama
More information about camh/laravel-ollama
Files in camh/laravel-ollama
Package laravel-ollama
Short Description Laravel client for Ollama (generate, chat, embeddings) with PII masking & JSON helpers.
License MIT
Informations about the package laravel-ollama
Laravel Ollama
A Laravel client for Ollama (local LLM): text generation, chat, embeddings, PII masking, and JSON guardrails.
Features
- Text Generation: Use local LLMs for text generation.
- Chat: Multi-turn conversations with context.
- Embeddings: Generate vector embeddings for text.
- PII Masking: Automatically mask sensitive info (emails, tokens, etc.).
- JSON Guardrails: Repair/validate JSON output from models.
- Artisan Commands: Manage models, chat, and more from CLI.
Installation
Configuration
Add to your .env:
Edit config/ollama.php for advanced options:
base: Ollama server URLdefault_model: Default model for generationembed_model: Model for embeddingstimeout: Request timeout (seconds)retries: Number of retriesmask_pii: Enable/disable PII maskingpii_patterns: Custom regex patterns for PII
Usage
You can interact with the package through the Ollama facade.
Generate Text
To generate a simple text completion:
You can also pass additional options, such as the model or temperature:
Chat Completions
For chat-based interactions, provide a history of messages:
Embeddings
To create embeddings for a given input:
Streaming Responses
For real-time responses, use the stream method with a callback:
JSON Mode
To receive a response in JSON format (auto-repairs invalid JSON):
You can also provide a JSON schema for structured output:
Persistent, Rich Conversations
You can manage multi-turn, persistent conversations using the Conversation class:
- Each conversation is identified by a unique ID (e.g., user/session ID).
- Conversations are automatically persisted in cache and can be loaded later.
- You can add metadata, limit history, or extend the Conversation class for more features.
Artisan Commands
Testing
Contributing
Pull requests and issues are welcome! Please see CONTRIBUTING.md if available.
License
MIT
All versions of laravel-ollama with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
guzzlehttp/guzzle Version ^7.8|^8.0