A sophisticated Retrieval-Augmented Generation (RAG) application that enhances LLM responses with contextual document retrieval and multi-stage verification.
This guide will help you set up and run the Advanced RAG application on your local machine.
Before you begin, make sure you have the following installed:
- Python 3.12 or higher
- Git
-
Clone the Repository
Open your terminal and run:
git clone https://github.com/segave/Advanced-RAG---LangGraph cd Advanced-RAG-LangGraph -
Install Poetry
# Install Poetry using pip pip install -r requirements.txt -
Install Project Dependencies
# Install all project dependencies poetry install # Activate the virtual environment poetry shell
-
Run the Application
Once you have activated the virtual environment with
poetry shell, you can run the application:# Make sure you are in the project directory streamlit run app.pyThe application will start and automatically open in your default web browser. If it doesn't open automatically, you can access it at:
- Local URL: http://localhost:8501
- Network URL: http://192.168.X.X:8501 (for accessing from other devices on your network)
-
Create Environment File
Copy the example environment file and add your API keys:
cp .env.example .env
Then edit the
.envfile and add your API keys:# Required OPENAI_API_KEY=your_openai_api_key TAVILY_API_KEY=your_tavily_api_key
-
Optional Environment Variables
You can customize these settings in your
.envfile:LANGCHAIN_API_KEY=your_langchain_api_key_here LANGCHAIN_PROJECT=your_project_name LANGCHAIN_TRACING_V2=true PYTHONPATH=your_project_path
- Upload and process multiple document formats:
- PDF documents (.pdf)
- Word documents (.docx)
- Text files (.txt)
- Automatic text chunking and vectorization
- Persistent vector storage using ChromaDB
- Multi-stage document retrieval and verification:
- Entry classification for query routing
- Contextual document retrieval
- Relevance grading of retrieved documents
- Response generation with context
- Hallucination detection
- Answer quality assessment
- Web search if needed
- Choose between different OpenAI models:
- GPT-4o
- GPT-4o-mini
- Dynamic model switching without application restart
- Upload interface for multiple documents
- Document database cleanup functionality
- Vector store persistence across sessions
- Efficient document chunking and retrieval
- Interactive chat with context-aware responses
- Chat history maintenance
- Clear conversation option
- Real-time response generation
- Automatic verification of responses against sources
- Detection of potential hallucinations
- Relevance scoring of retrieved documents
- Answer quality assessment
If you prefer to use Docker, you can run the application using our Docker image (available on Docker Hub):
-
Pull the Docker image:
docker pull sergiogaliana/advanced-rag-langgraph:latest
-
Run the container with environment variables:
docker run -p 8501:8501 \ -e OPENAI_API_KEY=your_key \ -e TAVILY_API_KEY=your_key \ sergiogaliana/advanced-rag-langgraph:latest
-
Create a docker-compose.yml file:
cp docker-compose.yml.example docker-compose.yml
-
Add your environment variables: Either edit the docker-compose.yml directly or create a .env file with your variables:
OPENAI_API_KEY=your_key TAVILY_API_KEY=your_key
-
Run the container:
docker-compose up
The application will be available at:
- Local URL: http://localhost:8501
More sections about configuration and usage will be added soon...