muradbdinfo/laravelai
Unified AI chat interface for Laravel with pluggable providers (Ollama, OpenAI/ChatGPT, Anthropic/Claude, DeepSeek). Includes quick setup, configuration, real-world examples, chat app integration, API reference, and built-in RAG support.
A full Projects system built into the Chat UI — create knowledge bases, upload documents, and chat with RAG-powered context scoped per project. Mirrors how Claude.ai Projects works, fully self-hosted.
New features:
.txt, .md, .pdf files; auto-ingested into RAG on uploadAI::rag()->source('project_5')->search($query) retrieves only that project's documents🧠 RAG ON when chatting inside a project sessionproject_id; normal sessions unaffectedcomposer require smalot/pdfparserBug fixes:
forgetDrivers() after embed call — prevents nomic-embed-text model bleeding into chat requestsfindOrFail() instead of route model binding — fixes 500 error for package-namespaced models->model() on every AI call — prevents shared driver state mutationob_get_level() check before ob_flush() — fixes "headers already sent" on Apache with output bufferingnum_ctx=2048 option for qwen2 models — fixes 400 error from context size too largeNew package files:
src/Chat/Models/Project.phpsrc/Chat/Models/ProjectFile.phpsrc/Chat/Controllers/ProjectController.phpsrc/Chat/Controllers/ProjectFileController.phpdatabase/migrations/2026_08_05_000001_create_ai_documents_table.phpdatabase/migrations/2026_08_06_000000_create_projects_and_files_tables.phpdatabase/migrations/2026_08_06_000001_add_project_id_to_chat_sessions.phpUpdated files:
src/RAG/RAGManager.php — source() scoping, forgetDrivers() fix, scoped flush()src/Chat/Models/ChatSession.php — project_id fillable + project() relationsrc/Chat/Controllers/AIChatController.php — RAG injection, explicit model, ob_flush fixroutes/chat.php — project and file routesresources/views/chat.blade.php — Projects UI, file manager modal, RAG indicatorsRAG API additions:
AI::rag()->source('project_5')->search($query);
AI::rag()->source('project_5')->ask($question);
AI::rag()->flush('project_5');
/ai-chatask() to prevent embed model bleeding over from previous embed() callrag config block outside providers arrayconfig() calls so config is always available at runtimeboot() instead of register()AI::rag()->ingest(string $content, string $source) — chunk text and store as embeddingsAI::rag()->ask(string $question) — answer questions using retrieved contextAI::rag()->search(string $query) — return top-K most relevant chunks with cosine similarity scoresAI::rag()->flush() — clear all stored documentsphp artisan ai:rag:ingest {path} — ingest files or directories from CLIai_documents table via loadMigrationsFrom.env (AI_RAG_PROVIDER, AI_RAG_EMBED_MODEL, AI_RAG_CHUNK_SIZE, AI_RAG_TOP_K, AI_RAG_TABLE)AI::rag()->ingest(), search(), ask(), flush()php artisan ai:rag:ingestAIResponse objectai() helperHow can I help you explore Laravel packages today?