laravel-meilisearch-rag maintained by performing
Laravel Meilisearch RAG
Meilisearch-backed RAG indexing for Laravel applications.
The package stores knowledge documents with plank/laravel-mediable, chunks extracted text, generates embeddings with laravel/ai, and indexes chunks into Meilisearch using user-provided vectors.
Installation
composer require performing/laravel-meilisearch-rag
For local path development, add the repository to the host app:
{
"repositories": [
{
"type": "path",
"url": "packages/laravel-meilisearch-rag"
}
],
"require": {
"performing/laravel-meilisearch-rag": "*"
}
}
Then run:
composer update performing/laravel-meilisearch-rag --with-dependencies
Configuration
Publish the config when you need to override defaults:
php artisan vendor:publish --tag=meilisearch-rag-config
Available environment variables:
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=
KNOWLEDGE_MEILISEARCH_INDEX=knowledge_chunks
KNOWLEDGE_MEILISEARCH_EMBEDDER=default
KNOWLEDGE_EMBEDDING_PROVIDER=openrouter
KNOWLEDGE_EMBEDDING_MODEL=text-embedding-3-small
KNOWLEDGE_EMBEDDING_DIMENSIONS=1536
KNOWLEDGE_CHUNK_SIZE=1200
KNOWLEDGE_CHUNK_OVERLAP=200
KNOWLEDGE_SEARCH_LIMIT=6
The Meilisearch embedder is configured as userProvided, so Laravel generates embeddings and Meilisearch stores/searches the vectors.
Migrations
Publish the package migrations:
php artisan vendor:publish --tag=meilisearch-rag-migrations
php artisan migrate
The package expects Plank Mediable migrations to be installed in the host application.
Usage
Store typed text through the command bus:
use Performing\MeilisearchRag\Commands\KnowledgeTextStoreCommand;
command(KnowledgeTextStoreCommand::from([
'title' => 'Shipping policy',
'content' => 'Long-form knowledge content...',
]));
Search indexed chunks:
use Performing\MeilisearchRag\Support\KnowledgeEmbeddings;
use Performing\MeilisearchRag\Support\KnowledgeMeilisearch;
$embedding = app(KnowledgeEmbeddings::class)->embed('How long does shipping take?');
$chunks = app(KnowledgeMeilisearch::class)->search('How long does shipping take?', $embedding);
Available package commands:
KnowledgeTextStoreCommandKnowledgeDocumentStoreCommandKnowledgeDocumentUpdateCommandKnowledgeDocumentReindexCommandKnowledgeDocumentDeleteCommand
Handlers are registered by the package service provider.
Model
The package model is:
Performing\MeilisearchRag\Models\KnowledgeDocument
If the host app uses Mediable morph maps, map the document type to this class.