Download the PHP package ayaashraf/laravel-rag without Composer
On this page you can find all versions of the php package ayaashraf/laravel-rag. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ayaashraf/laravel-rag
More information about ayaashraf/laravel-rag
Files in ayaashraf/laravel-rag
Package laravel-rag
Short Description A production-ready RAG (Retrieval-Augmented Generation) package for Laravel using pgvector and Livewire
License MIT
Informations about the package laravel-rag
Laravel RAG Package
A production-ready Retrieval-Augmented Generation (RAG) package for Laravel using pgvector and Livewire.
Features
- 🔍 Vector Semantic Search using pgvector with PostgreSQL
- 📄 Multi-format Document Processing (PDF, DOCX, TXT, XLS, XLSX, CSV)
- 🧠 AI-powered Document Chunking with configurable strategies
- 💬 Real-time Streaming Chat using Laravel AI SDK
- ⚡ Full-text to Vector Pipeline with embeddings caching
- 🎯 Bilingual Support with Arabic language optimization
- 📊 Analytics Dashboard with token counting and timing metrics
- 🔧 Swappable Embedding Providers (Gemini, OpenAI, Cohere, Azure, etc.)
- 🎨 Beautiful Livewire UI with Tailwind CSS & Alpine.js
Installation
Publishing Assets
Publish configuration, migrations, and views:
Run migrations:
Configuration
Create a PostgreSQL connection for vectors in config/database.php:
Configure environment variables in .env:
Usage
In Blade Templates
Programmatic Usage
With Callback Hooks
Database Schema
Documents Table
Stores document metadata on MySQL/Primary DB:
Document Chunks Table
Stores vector embeddings on PostgreSQL with pgvector:
Architecture
The package uses a multi-database approach:
- MySQL/Primary: Document metadata (fast lookups)
- PostgreSQL + pgvector: Vector embeddings (semantic search)
This separation allows:
- Optimal query performance
- Easy backup of metadata
- Scalable vector operations
Configuration Options
All options can be set via config/rag.php or .env variables:
| Option | Env Var | Default | Description |
|---|---|---|---|
| embedding_provider | RAG_EMBEDDING_PROVIDER | gemini | AI provider for embeddings |
| vector_connection | RAG_VECTOR_CONNECTION | pgsql_vector | PostgreSQL connection name |
| documents_connection | RAG_DOCUMENTS_CONNECTION | mysql | Metadata DB connection |
| min_similarity | RAG_MIN_SIMILARITY | 0.45 | Threshold for English queries |
| arabic_min_similarity | RAG_ARABIC_MIN_SIMILARITY | 0.30 | Threshold for Arabic queries |
| embedding_dimensions | RAG_EMBEDDING_DIMENSIONS | 768 | Vector dimensions |
| chunk_size | RAG_CHUNK_SIZE | 1000 | Characters per chunk |
| chunk_overlap | RAG_CHUNK_OVERLAP | 200 | Overlap between chunks |
| max_search_results | RAG_MAX_SEARCH_RESULTS | 10 | Max chunks to retrieve |
| storage_disk | RAG_STORAGE_DISK | rag_documents | Storage disk for files |
| chunker_strategy | RAG_CHUNKER_STRATEGY | character | Chunking strategy |
| chat.provider | RAG_CHAT_PROVIDER | gemini | Chat completion provider |
| chat.model | RAG_CHAT_MODEL | gemini-2.0-flash | Chat model name |
| chat.timeout | RAG_CHAT_TIMEOUT | 120 | Request timeout in seconds |
Advanced Usage
Custom Embedding Providers
Create your own embedding implementation:
Manual Document Processing
Performance Tips
-
Use Queue Workers for document processing:
-
Enable Embedding Caching in
config/ai.php: -
Batch Imports for large document sets:
- Tune Similarity Threshold based on your documents:
- Lower threshold (0.30) = More results, lower precision
- Higher threshold (0.70) = Fewer results, higher precision
Troubleshooting
Vector Search Returns No Results
Check the similarity threshold:
Out of Memory During PDF Processing
Limit PDF size or process asynchronously:
Embedding API Rate Limiting
Reduce batch size in config/rag.php:
Testing
Run the package tests:
License
MIT License - see LICENSE file for details.
Support
For issues, questions, or contributions, please visit the GitHub repository.
Made with ❤️ for Laravel developers
All versions of laravel-rag with dependencies
laravel/framework Version ^12.0
laravel/ai Version ^0.6.8
livewire/livewire Version ^3.0 || ^4.0
pgvector/pgvector Version ^0.2.0
spatie/pdf-to-text Version ^1.55
phpoffice/phpspreadsheet Version ^5.7
phpoffice/phpword Version ^1.4
smalot/pdfparser Version ^2.12