This guide explains how to run the Paperless-AI application with the RAG service in a local development environment without Docker.
The integration consists of two main components:
- Python RAG Service (main.py): Handles document indexing, search, and context retrieval
- Node.js Integration: Manages the UI, communicates with the Python service, and uses LLMs to generate responses
In production, both services run in the same Docker container, but for development, you can run them separately.
- Node.js 16+ for the main Paperless-AI application
- Python 3.10+ for the RAG service
- A running Paperless-NGX instance (for document access)
- Make sure you have all dependencies installed:
# Install Node.js dependencies
npm install
# Install Python dependencies
pip install -r requirements.txt- Configure your
.envfile in thedatadirectory with your Paperless-NGX credentials:
PAPERLESS_API_URL=https://your-paperless-ngx-instance
PAPERLESS_API_TOKEN=your-api-token
Note: The Python service will also read the existing API settings from this file (PAPERLESS_API_URL).
- Run both services using the provided script:
# Make the script executable first (Linux/macOS)
chmod +x start-services.sh
# Run the services
./start-services.sh- Install Python dependencies:
pip install -r requirements.txt- Start the Python RAG service:
python main.py --host 127.0.0.1 --port 8000 --initializeThe --initialize flag will build the document index on startup.
- Set the environment variables for the Node.js application:
For Windows (Command Prompt):
set RAG_SERVICE_URL=http://localhost:8000
set RAG_SERVICE_ENABLED=trueFor Windows (PowerShell):
$env:RAG_SERVICE_URL="http://localhost:8000"
$env:RAG_SERVICE_ENABLED="true"For Linux/macOS:
export RAG_SERVICE_URL=http://localhost:8000
export RAG_SERVICE_ENABLED=true- Start the Paperless-AI application in development mode:
npm run devOpen your browser and navigate to:
http://localhost:3000/rag
You should see the RAG interface where you can ask questions about your documents.
-
The Python service looks for these variables in this order:
- For API URL:
PAPERLESS_API_URL, thenPAPERLESS_URL, thenPAPERLESS_NGX_URL, thenPAPERLESS_HOST - For API Token:
PAPERLESS_TOKEN, thenPAPERLESS_API_TOKEN, thenPAPERLESS_APIKEY
- For API URL:
-
If you're using different variable names in your existing
.envfile, the Python service should still find them.
- Missing Documents: Check that the indexing has completed. You can check the status at
http://localhost:8000/indexing/status. - Connection Errors: Ensure your Paperless-NGX credentials are correct and the instance is accessible.
- Port Conflicts: If port 8000 is already in use, specify a different port with the
--portparameter and update theRAG_SERVICE_URLenvironment variable accordingly.
When making changes to the codebase:
-
Python RAG Service Changes:
- Edit
main.py - Restart the Python service to apply changes
- Edit
-
Paperless-AI Integration Changes:
- Edit Node.js files (like
services/ragService.jsorroutes/rag.js) - If using nodemon (with
npm run dev), changes should be applied automatically - For UI changes to
views/rag.ejs, refresh the browser
- Edit Node.js files (like