⚡Ship RAG Solutions Quickly and effortlessly
OTHER License
Setting up reliable RAG systems can be time-consuming and complex. RAG-SaaS allows developers to focus on fine-tuning and developing their RAG pipeline rather than worrying about packaging it into a usable application. Built on top of create-llama by LlamaIndex, RAG-SaaS provides a solid foundation for your RAG-based projects.
git clone https://github.com/adithya-s-k/RAG-SaaS.git
cd RAG-SaaS
To properly configure and run RAG-SaaS, you need to set up several environment variables. These are divided into three main sections: Frontend, Backend, and Docker Compose. Here's a detailed explanation of each:
NEXT_PUBLIC_SERVER_URL
: (Compulsory) The endpoint URL of your FastAPI server.NEXT_PUBLIC_CHAT_API
: (Compulsory) Derived from NEXT_SERVER_URL, typically set to ${NEXT_PUBLIC_SERVER_URL}/api/chat
.Model Configuration:
MODEL_PROVIDER
: (Compulsory) The AI model provider (e.g., 'openai').MODEL
: (Compulsory) The name of the LLM model to use.EMBEDDING_MODEL
: (Compulsory) The name of the embedding model.EMBEDDING_DIM
: (Compulsory) The dimensionality of the embedding model.OpenAI Configuration:
OPENAI_API_KEY
: (Compulsory) Your OpenAI API key.Application Settings:
CONVERSATION_STARTERS
: (Compulsory) A list of starter questions for users.SYSTEM_PROMPT
: (Compulsory) The system prompt for the AI model.SYSTEM_CITATION_PROMPT
: (Optional) Additional prompt for citation.APP_HOST
: (Compulsory) The host address for the backend (default: '0.0.0.0').APP_PORT
: (Compulsory) The port for the backend (default: 8000).Database Configuration:
MONGODB_URI
: (Compulsory) The MongoDB connection URI.MONGODB_NAME
: (Compulsory) The MongoDB database name (default: 'RAGSAAS').QDRANT_URL
: (Compulsory) The URL for the Qdrant server.QDRANT_COLLECTION
: (Compulsory) The Qdrant collection name.QDRANT_API_KEY
: (Optional) API key for Qdrant authentication.Authentication:
JWT_SECRET_KEY
: (Compulsory) Secret key for signing JWT tokens.JWT_REFRESH_SECRET_KEY
: (Compulsory) Secret key for signing JWT refresh tokens.ADMIN_EMAIL
: (Compulsory) Administrator email for application login.ADMIN_PASSWORD
: (Compulsory) Administrator password for application login.AWS S3 Configuration (Optional):
AWS_ACCESS_KEY_ID
: AWS Access Key ID.AWS_SECRET_ACCESS_KEY
: AWS Secret Access Key.AWS_REGION
: AWS Region for your services.BUCKET_NAME
: The name of the S3 bucket to use.Observability:
ARIZE_PHOENIX_ENDPOINT
: (Optional) Endpoint for Arize Phoenix observability.To enable S3 integration for PDF uploads/Ingestion:
.env
file:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=bucket_region
BUCKET_NAME=your_bucket_name
backend:
build:
context: ./backend
dockerfile: Dockerfile
image: ragsaas/backend:latest
container_name: backend
ports:
- '8000:8000'
environment:
# MongoDB Configuration
MONGODB_NAME: RAGSAAS
MONGODB_URI: mongodb://admin:password@mongodb:27017/
# Qdrant Configuration
QDRANT_COLLECTION: default
QDRANT_URL: http://qdrant:6333
# QDRANT_API_KEY:
# OPENAI_API_KEY is compulsory
OPENAI_API_KEY:
# Backend Application Configuration
MODEL_PROVIDER: openai
MODEL: gpt-4o-mini
EMBEDDING_MODEL: text-embedding-3-small
EMBEDDING_DIM: 1536
FILESERVER_URL_PREFIX: http://backend:8000/api/files
SYSTEM_PROMPT: 'You are a helpful assistant who helps users with their questions.'
APP_HOST: 0.0.0.0
APP_PORT: 8000
JWT_SECRET_KEY:
JWT_REFRESH_SECRET_KEY:
ARIZE_PHOENIX_ENDPOINT: http://arizephoenix:4317
For Docker Compose deployment, use:
docker compose up -d
Pull down the containers
docker compose down
To run the project in development mode, follow these steps:
Start the Next.js Frontend:
Navigate to the frontend
directory and install the required dependencies. Then, run the development server:
cd frontend
npm install
npm run dev
Set Up the Vector Database (Qdrant), Database (MongoDB), and Observability Platform (Arize Phoenix):
You can either self-host these services using Docker or use hosted solutions.
Self-Hosted Options:
Qdrant:
docker pull qdrant/qdrant
MongoDB:
docker pull mongo
Arize Phoenix:
docker pull arizephoenix/phoenix
Hosted Options:
Start the FastAPI Server:
Navigate to the backend
directory and set up the Python environment. You can use either Conda or Python's built-in venv
:
cd backend
Using Conda:
conda create -n ragsaas-venv python=3.11
conda activate ragsaas-venv
Using Python's venv
:
python -m venv ragsaas-venv
\ragsaas-venv\Scripts\activate # On Windows
source ragsaas-venv/bin/activate # On macOS/Linux
Install the required dependencies and run the server:
pip install -e .
python main.py
We welcome contributions to RAG-SaaS! Please see our CONTRIBUTING.md for more details on how to get started.
This project is available under a dual license:
See the LICENSING.md file for more details.
This project is built on the following frameworks, technologies and tools:
If you encounter any issues or bugs, please report them in the Issues tab of our GitHub repository.
For inquiries regarding:
Please contact: [email protected]
We're here to help tailor RAG-SaaS to your specific needs and ensure you get the most out of our solution.