Enterprise RAG system for knowledge management
Project description
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.
Project details
Release history Release notifications | RSS feed
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
|