A Retrieval-Augmented Generation (RAG) system built with Django, PostgreSQL (pgvector), and LangChain. This system allows users to upload documents, search them using vector embeddings, and ask questions to receive AI-generated answers based on the document context.
- Document Management: Upload and manage text documents via Django Admin.
- Vector Search: Automatically generates embeddings (using
all-MiniLM-L6-v2) and performs semantic search using PostgreSQLpgvector. - RAG QA System: Uses
LangChainandzephyr-7b-beta(via Hugging Face API) to answer user questions based on stored documents. - Dockerized: Fully containerized setup for easy deployment.
- Docker and Docker Compose installed on your machine.
- A Hugging Face Access Token (for the LLM feature).
-
Clone the project: Extract the project files to your local machine.
-
Configure Environment: Rename
.env.samplefile to.envand find the variables and change its values to the desire value. -
Build and Run:
docker compose up -d --build- Apply Migrations:
docker compose run web python manage.py migrate- Create Superuser (Admin):
docker compose run web python manage.py createsuperuserYou can import documents from a CSV file (e.g., data.csv):
docker compose run web python manage.py import_documents data.csvAccess the admin panel at http://localhost:8000/admin to manage documents and view query logs.
- URL: POST /api/search/
- Body:
{
"query": "What is reinforcement learning?",
"top_k": 3
}- URL: POST /api/ask/
- Body:
{
"question": "How does Git help developers?"
}- Response: Returns the AI-generated answer and the source documents used.