feat: complete Phase 1-4 - Production-ready RAG package with full test coverage - #2
Merged
Merged
Conversation
Add production-ready Retrieval-Augmented Generation (RAG) package for Laravel with strict typing, batch operations, and enterprise-grade code quality. Phase 1 - Core Abstractions: - Define 7 core interfaces (DataSource, Chunker, EmbeddingDriver, etc.) - Implement TextDataSource and TextChunker with metadata preservation - Create database migration with unique constraints and soft deletes - Add custom exception hierarchy with factory methods - Implement RagLogger with structured logging and trace IDs Phase 2 - Ingestion Pipeline: - Implement OpenAIEmbeddingDriver with embedBatch() support - Implement PgVectorStore with storeMany() and duplicate handling - Create IngestionPipeline with batch operations - Add rag:ingest Artisan command Phase 3 - Query Pipeline: - Implement SimilarityRetriever (accepts string query) - Implement SimplePromptBuilder with token limits - Implement OpenAILlmDriver with streaming support - Create QueryPipeline service - Add rag:query Artisan command Phase 4 - Laravel Integration: - Create RagServiceProvider with match-based provider selection - Create Rag facade for easy access - Add config/rag.php with all driver configurations - Set up OpenCode configuration (agents, commands, skills) - Create AGENTS.md with global system rules Code Quality: - All files use declare(strict_types=1) - Explicit parameter and return types throughout - Readonly constructor properties - PHPStan level 6+ compatible (0 errors) - Batch operations for performance (embedBatch, storeMany) - JSON_THROW_ON_ERROR used consistently Documentation: - Complete README with installation and usage examples - AGENTS.md with architecture rules and development workflow - IMPLEMENTATION_PLAN.md with 4-phase breakdown
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix RagServiceProvider to correctly read data_source.type from the config array (was passing the whole array to match). Defer API key validation to call time in drivers so Larastan can boot the app without env vars set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete implementation of a production-ready, provider-agnostic RAG package for Laravel with 4 phases:
rag:ingestcommand)rag:querycommand)Changes in this PR
RagManageras the'rag'singleton--topKoption torag:querycommandTest Plan
declare(strict_types=1);readonlyQuality Checklist
embedBatch,storeMany)JSON_THROW_ON_ERRORfor all JSON decoding