lemukarram/laravel-ai-rag

The Ultimate Laravel AI RAG Package. Seamlessly integrate Vector Search with GPT-5.5, Gemini 2.5, and Claude 4.6. Advanced semantic search for Eloquent models.

Maintainers

Package info

github.com/lemukarram/vector-search

pkg:composer/lemukarram/laravel-ai-rag

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v1.0.0 2026-06-02 14:18 UTC

This package is auto-updated.

Last update: 2026-06-02 14:26:49 UTC


README

Latest Version on Packagist Total Downloads License

Laravel AI RAG is the ultimate developer toolkit for building production-ready Retrieval-Augmented Generation (RAG) applications. It seamlessly bridges your Eloquent models with cutting-edge Vector Databases and Frontier LLMs like GPT-5.5, Gemini 2.5, and Claude 4.6.

๐Ÿ› ๏ธ Detailed Installation Guide

1. Requirements

  • PHP 8.2 or higher
  • Laravel 10.x, 11.x, or 12.x
  • A vector store account (Upstash, Pinecone, or a local Chroma instance)

2. Install via Composer

composer require lemukarram/laravel-ai-rag

3. Publish Configuration

Publish the vector-search.php config file to your application:

php artisan vendor:publish --provider="LeMukarram\VectorSearch\VectorSearchServiceProvider"

โš™๏ธ Exhaustive Configuration Reference

Open config/vector-search.php to manage your environment.

๐Ÿ“‚ Vector Store Settings

Driver Env Variable Description
Global VECTOR_STORE Default store to use (upstash, pinecone, chroma)
Upstash UPSTASH_VECTOR_URL Your Upstash Vector REST URL
Upstash UPSTASH_VECTOR_TOKEN Your Upstash REST Token
Pinecone PINECONE_API_KEY Your Pinecone API Key
Pinecone PINECONE_HOST The index host (e.g., https://index-xyz.svc.pinecone.io)
Chroma CHROMA_HOST Hostname (Default: 127.0.0.1)
Chroma CHROMA_PORT Port (Default: 8000)
Chroma CHROMA_COLLECTION Collection name (Default: laravel-rag)

๐Ÿง  AI Model Settings

Provider Env Variable Description
OpenAI OPENAI_API_KEY Your OpenAI Secret Key
Gemini GEMINI_API_KEY Your Google AI (Gemini) API Key
Anthropic ANTHROPIC_API_KEY Your Anthropic API Key
DeepSeek DEEPSEEK_API_KEY Your DeepSeek API Key

โšก RAG Logic & Chunking

Configure these in the rag array of your config file:

  • chunk_size: Maximum characters per vector (Default: 1000)
  • chunk_overlap: Character overlap between chunks (Default: 200)
  • system_prompt: The core instruction for the LLM. Supports {{context}} and {{query}} placeholders.

๐Ÿš€ Pro Use Cases & Examples

Use Case 1: Intelligent Documentation Search

Index your technical docs and allow users to ask questions.

// In your Model
public function getVectorColumns(): array {
    return ['title', 'body', 'version_tag'];
}

// In your Controller
$answer = VectorSearch::whereMetadata('version_tag', 'v3.0')
    ->chat('How do I configure the new hybrid search?');

Use Case 2: AI-Powered E-commerce Product Recommendations

Find products not just by name, but by "vibe" or semantic description.

// Search for "summer vibe outdoor clothes"
$products = VectorSearch::withStore('pinecone') // Use high-performance index
    ->similar('Lightweight breathable clothing for hiking', topK: 10);

Use Case 3: Legal/Medical Document Analysis

Use Claude 4.6 for high-precision reasoning over complex text.

$analysis = VectorSearch::withModel('anthropic')
    ->chat('Summarize the liability clauses in the retrieved contracts.');

Use Case 4: Global Support Bot (Multi-Query Expansion)

When users ask vague questions, use multiQuery to find better answers.

// Automatically generates 3 variations of the user's query
$results = VectorSearch::multiQuery('Payment failed'); 

๐Ÿงช Testing

use LeMukarram\VectorSearch\Facades\VectorSearch;

public function test_it_works()
{
    $fake = VectorSearch::fake();
    $fake->pushChatResponse('Laravel AI RAG is awesome!');

    $response = VectorSearch::chat('What is this package?');
    
    $this->assertEquals('Laravel AI RAG is awesome!', $response->content());
}

๐Ÿ“ˆ Search Performance & SEO Tips

Keywords: Laravel AI, Vector Search Laravel, RAG Laravel, GPT-5 Laravel, Gemini AI Laravel, PHP AI Package, Semantic Search PHP, Pinecone Laravel, Upstash Vector Laravel, AI Embedding Laravel.

๐Ÿค Support & License

If you find this package useful, please star the repository on GitHub! Licensed under the MIT License.