AI RAG Enterprise Knowledge Base
A production-grade Retrieval-Augmented Generation (RAG) system for enterprise knowledge management. Ingest documents, build semantic indexes, and query your knowledge base using natural language.
🚀 Features
- Multi-format Document Ingestion: PDF, DOCX, TXT, Markdown, HTML
- Semantic Search: ChromaDB vector store with sentence-transformers embeddings
- LLM Integration: OpenAI GPT-4, Anthropic Claude, or local models via Ollama
- REST API: FastAPI with OpenAPI documentation
- Authentication: JWT-based auth with role-based access control
- Async Processing: Background document processing with Celery
- Observability: Structured logging, Prometheus metrics, health checks
📁 Project Structure
ai-rag-enterprise-knowledge-base/
├── src/
│ ├── api/ # FastAPI routes
│ │ ├── __init__.py
│ │ ├── documents.py # Document upload/management
│ │ ├── query.py # RAG query endpoints
│ │ └── auth.py # Authentication
│ ├── core/ # Core RAG logic
│ │ ├── __init__.py
│ │ ├── embeddings.py # Embedding models
│ │ ├── vectorstore.py # ChromaDB integration
│ │ ├── retriever.py # Document retrieval
│ │ ├── llm.py # LLM abstraction
│ │ └── chains.py # LangChain RAG chains
│ ├── ingestion/ # Document processing
│ │ ├── __init__.py
│ │ ├── loaders.py # File loaders
│ │ ├── chunkers.py # Text splitting
│ │ └── pipeline.py # Ingestion pipeline
│ ├── models/ # Pydantic models
│ │ ├── __init__.py
│ │ ├── documents.py
│ │ └── queries.py
│ ├── config.py # Configuration
│ └── main.py # Application entrypoint
├── tests/
│ ├── conftest.py
│ ├── test_api/
│ ├── test_core/
│ └── test_ingestion/
├── docker-compose.yml
├── Dockerfile
├── pyproject.toml
├── requirements.txt
└── README.md
🛠️ Installation
# Clone the repository
git clone https://github.com/Shivay00001/ai-rag-enterprise-knowledge-base.git
cd ai-rag-enterprise-knowledge-base
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set environment variables
cp .env.example .env
# Edit .env with your API keys
# Run the application
uvicorn src.main:app --reload
🐳 Docker
docker-compose up -d
📖 API Usage
Upload Document
curl -X POST "http://localhost:8000/api/v1/documents" \
-H "Authorization: Bearer $TOKEN" \
-F "file=@knowledge_base.pdf"
Query Knowledge Base
curl -X POST "http://localhost:8000/api/v1/query" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"question": "What is our refund policy?", "top_k": 5}'
⚙️ Configuration
| Variable | Description | Default |
|---|---|---|
OPENAI_API_KEY |
OpenAI API key | - |
EMBEDDING_MODEL |
Embedding model name | all-MiniLM-L6-v2 |
LLM_MODEL |
LLM model name | gpt-4-turbo-preview |
CHROMA_PERSIST_DIR |
ChromaDB storage path | ./data/chroma |
CHUNK_SIZE |
Document chunk size | 1000 |
CHUNK_OVERLAP |
Chunk overlap | 200 |
🧪 Testing
pytest tests/ -v --cov=src
📄 License
MIT License - see LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_rag_enterprise_knowledge_base-1.0.0.tar.gz.
File metadata
- Download URL: ai_rag_enterprise_knowledge_base-1.0.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fafcaa5608012cc58a1f10cf2daadc54614353b799e599b173f84f290e2c8060
|
|
| MD5 |
25ce30e057873434366c735d86ec9385
|
|
| BLAKE2b-256 |
5f5b05e9c5026c1d3838db7d8d197a700e4a5aa1416fc09b589e94a7d8ad8239
|
File details
Details for the file ai_rag_enterprise_knowledge_base-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ai_rag_enterprise_knowledge_base-1.0.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
658c88ee7414e82fa40a16b3ab809e2a8a7b58be6195927c6c83103d0a05988a
|
|
| MD5 |
a9cfd638fb86017dd0b880f87b0dc6b8
|
|
| BLAKE2b-256 |
ab0f9c9040f6445fb256579d8abd15d898e3b6472d90c613beff1fe8e25395e0
|