A Retrieval-Augmented Generation (RAG) system that combines Milvus vector database with LangChain and OpenAI for intelligent document querying and response generation.
This system implements RAG architecture to provide accurate, context-aware responses to questions by:
- Storing document embeddings in Milvus vector database
- Retrieving relevant context when queried
- Generating human-like responses using OpenAI's language models
- Uses Milvus for efficient vector similarity search
- Stores document embeddings using OpenAI's embedding model
- Handles document addition and retrieval operations
- Configurable connection settings for Milvus database
- Implements the core RAG logic
- Integrates OpenAI's ChatGPT for response generation
- Manages the retrieval-generation pipeline
- Configurable temperature and other LLM parameters
- Handles document loading and chunking
- Configurable chunk size and overlap
- Supports text documents (expandable to other formats)
- Python 3.12+
- Docker and Docker Compose
- OpenAI API key
- Clone the repository:
git clone [repository-url]
cd RAG-System- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
# Create .env file with your OpenAI API key
echo "OPENAI_API_KEY=your_key_here" > .env- Start Milvus services:
docker-compose up -d- Add your documents to the data directory:
mkdir data
echo "Your document content here" > data/test_document.txt- Run the system:
python main.pyRun tests with coverage:
pytest -q --maxfail=1 --disable-warnings --cov=src --cov-report=term-missingRun linting:
flake8- Host: localhost (default)
- Port: 19530 (default)
- Configurable in src/config/settings.py
- Chunk size: 1000 (default)
- Chunk overlap: 0 (default)
- Configurable in src/config/settings.py
- Model: OpenAI ChatGPT
- Temperature: 0.2 (default)
- Configurable in src/config/settings.py
This RAG system is ideal for:
- Document question-answering
- Knowledge base augmentation
- Contextual information retrieval
- Research assistance
- Technical documentation queries
The system uses several Docker containers:
- Milvus standalone server
- Etcd for metadata storage
- MinIO for object storage
Access MinIO console:
- URL: http://localhost:9015
- Credentials: minioadmin/minioadmin
The system can be extended with:
- Additional document types (PDF, HTML, etc.)
- Custom embedding models
- Alternative vector databases
- Web interface
- Batch processing
- Caching mechanisms
Contributions are welcome! Please feel free to submit pull requests.
[Your license information here]