An AI-powered application that analyzes PDFs using the Retrieval-Augmented Generation (RAG) technique to deliver accurate, context-aware answers from your documents.
It simply works by uploading a PDF and prompting the LLM questions about the document.
Built with:
- User uploads a document (PDF)
- The system processes the document
- Once processing is complete, the user can prompt the LLM for queries related to the document.
- Users can start new conversations or continue from previous sessions.
- User uploads a PDF
- Text is extracted from the PDF using Smalot PDF Parser package.
- The extracted text is segmented into smaller chunks for efficient processing and to meet the embedding model context.
- Each chunk is sent to an embedding model to generate vector representations.
- The resulting vectors are stored in a vector database for retrieval.
- When the user submits a query, the system performs a similarity search in the vector database using the RAG (Retrieval-Augmented Generation) technique to find relevant context.
- The retrieved context is passed to the LLM, which generates a context-aware response.
- The LLM’s response is returned and displayed to the user through a chatbot interface.
-
Manager Design Pattern- The system uses a Manager pattern, allowing easy configuration and switching between different Vector Databases and LLMs. -
Queues- Each text chunk is enqueued as an individual job. Batchable jobs are grouped together and processed in parallel to optimize throughput and performance. -
Job Middleware- To comply with the LLM’s rate limits, a middleware enforces a rate limit of 100 requests per minute (RPM) for job execution. -
Reverb- A real-time communication layer that enables live tracking of job progress and interactive chatbot updates. It uses event-driven architecture with WebSockets to broadcast job state changes, logs, and chatbot messages as they occur.
-
Copy this repository
-
Copy the
.env.exampleto.env -
Setup the database connection
-
Install
Composercomposer install
-
Generate the application key
php artisan key:generate
-
Migrate and seed the database
php artisan migrate:fresh --seed
-
Run the project
php artisan serve