A production-ready, switchable-component AI information integration system with RAG (Retrieval-Augmented Generation) capabilities for enterprise document Q&A.
AIP is designed to solve two core enterprise needs:
-
Information Integration Pipeline: Aggregate data from multiple sources (arXiv, NewsAPI), analyze with LLM, and deliver reports to various destinations (Email, Notion, Slack)
-
Enterprise Document Q&A (RAG): Upload internal documents and ask questions with source citations - perfect for company policies, technical docs, and knowledge bases
| Feature | Description |
|---|---|
| π Switchable Components | Swap LLM/Source/Output providers via environment variables |
| π RAG System | Upload documents, ask questions, get answers with citations |
| π’ Enterprise Ready | AWS Bedrock & Azure support for data privacy |
| π Multi-format Support | PDF, Word, Markdown document processing |
βββββββββββββββββββββββββββββββββββββββ
β FastAPI β
β (REST API Layer) β
βββββββββββββββββ¬ββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Pipeline β β RAG Service β β Document β
β Service β β (Q&A) β β Processor β
ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Adapter Layer β
β βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ β
β β LLM Adapter β βSource Adapter β βOutput Adapter β βVector Store β β
β βββββββββββββββββ€ βββββββββββββββββ€ βββββββββββββββββ€ βββββββββββββββββ€ β
β β β’ Claude API β β β’ arXiv β β β’ Console β β β’ Chroma β β
β β β’ AWS Bedrock β β β’ NewsAPI β β β’ Notion β β β’ PgVector β β
β β β’ Azure OpenAIβ β β’ Internal DB β β β’ Email β β β’ Azure AI β β
β βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ β
β β
β βββββββββββββββββ β
β β Embedding β β
β βββββββββββββββββ€ β
β β β’ OpenAI β β
β β β’ Bedrock β β
β βββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Design Principles:
- Dependency Inversion: All adapters implement abstract interfaces
- Factory Pattern: Runtime provider selection via configuration
- Single Responsibility: Each adapter handles one specific task
- Python 3.10+
- uv (recommended) or pip
- API Keys: Anthropic (Claude) and/or OpenAI
# Clone repository
git clone https://github.com/ChengYuChuan/adaptive-intelligence-pipeline.git
cd adaptive-intelligence-pipeline
# Install with uv (recommended)
uv sync
# Or with pip
pip install -r requirements.txt# Copy example environment file
cp .env.example .env
# Edit .env with your API keysMinimum configuration:
# LLM
LLM_PROVIDER=claude
ANTHROPIC_API_KEY=sk-ant-api03-xxxxx
# RAG (for document Q&A)
EMBEDDING_PROVIDER=openai
OPENAI_API_KEY=sk-xxxxx
VECTORSTORE_PROVIDER=chroma# With uv
uv run uvicorn app.main:app --reload
# Or directly
uvicorn app.main:app --reloadOpen http://localhost:8000/docs for the Swagger UI.
Fetch data from sources, analyze with LLM, and output reports.
# Academic paper tracking
curl -X POST "http://localhost:8000/pipeline/run" \
-H "Content-Type: application/json" \
-d '{
"query": "machine learning transformers",
"template": "academic",
"max_results": 10,
"date_range": "last_week"
}'
# Financial news analysis
curl -X POST "http://localhost:8000/pipeline/run" \
-H "Content-Type: application/json" \
-d '{
"query": "TSMC NVIDIA semiconductor",
"template": "financial",
"max_results": 20,
"date_range": "today"
}'Upload documents and ask questions with source citations.
# Upload a PDF
curl -X POST "http://localhost:8000/documents/upload" \
-F "file=@company_policy.pdf" \
-F "tags=policy,hr" \
-F "description=Employee handbook 2024" \
-F "collection_name=default"
# Upload Markdown
curl -X POST "http://localhost:8000/documents/upload" \
-F "file=@technical_guide.md" \
-F "tags=technical,engineering" \
-F "collection_name=default"curl -X POST "http://localhost:8000/ask" \
-H "Content-Type: application/json" \
-d '{
"question": "What is the remote work policy?",
"collection_name": "default",
"top_k": 5,
"include_sources": true
}'Response:
{
"question": "What is the remote work policy?",
"answer": "According to the Employee Handbook, employees may work remotely up to 3 days per week with manager approval...",
"sources": [
{
"filename": "company_policy.pdf",
"content_preview": "Remote Work Guidelines: Employees may...",
"relevance_score": 0.89,
"page_number": 15
}
],
"retrieval_time_ms": 150,
"generation_time_ms": 2500
}# List collections
curl http://localhost:8000/rag/collections
# Get collection stats
curl http://localhost:8000/rag/collections/default/stats
# Delete collection
curl -X DELETE http://localhost:8000/rag/collections/default| Category | Options | Default |
|---|---|---|
| LLM | claude, bedrock, azure |
claude |
| Source | arxiv, newsapi, internal |
arxiv |
| Output | console, notion, email, slack |
console |
| Vector Store | chroma, pgvector, azure |
chroma |
| Embedding | openai, bedrock, local |
openai |
# ===== LLM Settings =====
LLM_PROVIDER=claude
ANTHROPIC_API_KEY=sk-ant-xxxxx
CLAUDE_MODEL=claude-sonnet-4-20250514
# AWS Bedrock (alternative)
# LLM_PROVIDER=bedrock
# AWS_REGION=us-west-2
# AWS_ACCESS_KEY_ID=xxxxx
# AWS_SECRET_ACCESS_KEY=xxxxx
# ===== Source Settings =====
SOURCE_PROVIDER=arxiv
NEWSAPI_KEY=xxxxx # For financial analysis
# ===== Output Settings =====
OUTPUT_PROVIDER=console
# Email settings
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password
EMAIL_FROM=your-email@gmail.com
EMAIL_TO=recipient@example.com
# ===== RAG Settings =====
VECTORSTORE_PROVIDER=chroma
CHROMA_PERSIST_DIR=./data/vectorstore
EMBEDDING_PROVIDER=openai
OPENAI_API_KEY=sk-xxxxx
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
# Document Processing
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
MAX_FILE_SIZE_MB=50
# ===== General =====
DEBUG=true
LOG_LEVEL=INFO| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API information |
| GET | /health |
Health check with provider info |
| GET | /config |
Current configuration |
| Method | Endpoint | Description |
|---|---|---|
| POST | /pipeline/run |
Execute data pipeline |
| Method | Endpoint | Description |
|---|---|---|
| POST | /documents/upload |
Upload document for processing |
| POST | /ask |
Ask question about documents |
| GET | /rag/health |
RAG system health |
| GET | /rag/collections |
List all collections |
| GET | /rag/collections/{name}/stats |
Collection statistics |
| DELETE | /rag/collections/{name} |
Delete collection |
adaptive-intelligence-pipeline/
βββ app/
β βββ main.py # FastAPI application
β βββ config.py # Environment settings
β β
β βββ adapters/ # Switchable components
β β βββ llm/ # LLM providers
β β β βββ base.py
β β β βββ claude_api.py # β
Implemented
β β β βββ bedrock.py # β
Implemented
β β β
β β βββ source/ # Data sources
β β β βββ base.py
β β β βββ arxiv.py # β
Implemented
β β β βββ newsapi.py # β
Implemented
β β β
β β βββ output/ # Output destinations
β β β βββ base.py
β β β βββ console.py # β
Implemented
β β β βββ notion.py # β
Implemented
β β β βββ email.py # β
Implemented
β β β
β β βββ vectorstore/ # Vector databases
β β β βββ base.py
β β β βββ chroma.py # β
Implemented
β β β βββ pgvector.py # π
Week 4
β β β
β β βββ embedding/ # Embedding services
β β βββ base.py
β β βββ openai.py # β
Implemented
β β
β βββ services/ # Business logic
β β βββ pipeline.py # Data pipeline orchestration
β β βββ document_processor.py # Document parsing & chunking
β β βββ rag.py # RAG Q&A service
β β
β βββ schemas/ # Pydantic models
β β βββ pipeline.py
β β βββ document.py
β β βββ rag.py
β β
β βββ prompts/ # LLM prompt templates
β βββ academic_summary.py
β βββ financial_analysis.py
β
βββ data/
β βββ documents/ # Uploaded documents
β βββ vectorstore/ # Chroma persistence
β
βββ tests/
βββ .github/workflows/ci.yml
βββ docker-compose.yml
βββ Dockerfile
βββ pyproject.toml
βββ README.md
- Framework: FastAPI 0.115+
- Package Manager: uv (recommended) / pip
- Validation: Pydantic 2.10+
- Claude: anthropic 0.39+
- AWS Bedrock: boto3 1.35+
- OpenAI Embedding: openai 1.12+
- Vector Store: chromadb 0.4+
- PDF Parsing: PyMuPDF 1.23+
- Word Parsing: python-docx 1.1+
- Tokenization: tiktoken 0.5+
- arXiv: arxiv 2.1+
- News: newsapi-python 0.2+
- Email: aiosmtplib 3.0+
- HTTP Client: httpx 0.27+
-
Week 1: Core Architecture
- FastAPI + Adapter Pattern
- Claude API LLM adapter
- arXiv source adapter
- Console & Notion output adapters
-
Week 2: Enterprise Adapters
- AWS Bedrock LLM adapter
- NewsAPI source adapter
- Email output adapter
-
Week 3: RAG System
- Chroma vector store adapter
- OpenAI embedding adapter
- Document processing (PDF/Word/Markdown)
- Question answering with citations
- Collection management APIs
- Week 4: Production Ready + Basic Monitoring
- PostgreSQL + pgvector adapter (AWS RDS / Azure)
- Bedrock Titan Embedding adapter
- Structured logging (JSON format)
-
/metricsendpoint (Prometheus format) - Basic monitoring dashboard
- Week 5+: Advanced Operations
- Full Prometheus + Grafana deployment
- Distributed tracing (OpenTelemetry)
- Alert configuration
- Cost monitoring dashboard
- n8n/Airflow scheduling integration
- Web dashboard UI
| Provider | Data Location | Best For |
|---|---|---|
| Claude API | Anthropic servers | Development, demos |
| AWS Bedrock | Your AWS account | Enterprise, regulated industries |
| Azure OpenAI | Your Azure tenant | Enterprise, Azure ecosystem |
- β
Use
.envfiles (never commit to git) - β Use AWS Secrets Manager / Azure Key Vault in production
- β Rotate credentials regularly
- β Use IAM roles instead of access keys when possible
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=app --cov-report=html
# Run specific tests
uv run pytest app/tests/test_rag.py -v# Build and run
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit changes:
git commit -m 'Add my feature' - Push to branch:
git push origin feature/my-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Yu-Chuan (Louis) Cheng
- MSc Scientific Computing, Heidelberg University
- Specialization: Machine Learning & Generative AI
- GitHub: @ChengYuChuan
- LinkedIn: Yu-Chuan Cheng