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.
Metadata
Release files for ai-rag-enterprise-knowledge-base 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ai_rag_enterprise_knowledge_base-1.0.0.tar.gz | 20.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ai_rag_enterprise_knowledge_base-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.7 kB
Release files / ai_rag_enterprise_knowledge_base-1.0.0.tar.gz
| Download URL | ai_rag_enterprise_knowledge_base-1.0.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fafcaa5608012cc58a1f10cf2daadc54614353b799e599b173f84f290e2c8060
|
|
BLAKE2b-256 checksum How to use checksums |
5f5b05e9c5026c1d3838db7d8d197a700e4a5aa1416fc09b589e94a7d8ad8239
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Release files / ai_rag_enterprise_knowledge_base-1.0.0-py3-none-any.whl
| Download URL | ai_rag_enterprise_knowledge_base-1.0.0-py3-none-any.whl |
|---|---|
| Size | 25.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
658c88ee7414e82fa40a16b3ab809e2a8a7b58be6195927c6c83103d0a05988a
|
|
BLAKE2b-256 checksum How to use checksums |
ab0f9c9040f6445fb256579d8abd15d898e3b6472d90c613beff1fe8e25395e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Security for ai-rag-enterprise-knowledge-base 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.