Production-grade AI engineering patterns, examples, and best practices for building LLM-powered applications.
This repository demonstrates modern AI engineering practices including:
- Multi-Provider LLM Support - Unified interface for OpenAI, Anthropic, and other providers
- Production Patterns - Rate limiting, retry logic, structured logging, error handling
- RAG Implementation - Vector search, document chunking, context augmentation
- Agent Architectures - ReAct pattern, tool use, multi-step reasoning
- Evaluation Framework - LLM-as-judge, automated quality assessment
- Hybrid ML/LLM Pipelines - When to use traditional ML vs. LLMs
# Clone the repository
git clone https://github.com/MysterionRise/ai-engineering-hub.git
cd ai-engineering-hub
# Install dependencies
pip install -e ".[dev]"
# Set up your API keys
export OPENAI_API_KEY="your-key-here"
export ANTHROPIC_API_KEY="your-key-here" # Optional
# Run an example
python examples/01-llm-fundamentals/basic_chat.pyai-engineering-hub/
├── src/ai_hub/ # Core library
│ ├── core/ # Config, errors, logging, retry utilities
│ ├── providers/ # LLM provider abstractions
│ └── utils/ # Token counting, text utilities
├── examples/ # Runnable examples by category
│ ├── 01-llm-fundamentals/ # Chat, streaming, structured output
│ ├── 02-multi-provider/ # Provider comparison and fallbacks
│ ├── 03-function-calling/ # Modern tools API usage
│ ├── 04-rag-patterns/ # Retrieval-augmented generation
│ ├── 05-agents/ # ReAct and agent patterns
│ ├── 06-evaluation/ # LLM-as-judge evaluation
│ ├── 07-fine-tuning/ # Data prep for fine-tuning
│ ├── 08-vision-multimodal/# Image analysis with Vision API
│ ├── 09-traditional-ml/ # When ML beats LLMs
│ └── 10-production-patterns/ # Rate limiting, caching
├── projects/ # Complete mini-projects
│ └── semantic_search/ # Full semantic search implementation
├── tests/ # Unit and integration tests
└── docs/ # Documentation
| Example | Description | Difficulty |
|---|---|---|
| Basic Chat | Single and multi-turn conversations | ⭐ |
| Streaming | Real-time response streaming | ⭐ |
| Structured Output | JSON mode and Pydantic validation | ⭐⭐ |
| Example | Description | Difficulty |
|---|---|---|
| Provider Comparison | Compare responses across providers | ⭐⭐ |
| Example | Description | Difficulty |
|---|---|---|
| Basic Tools | Modern tools API with execution loop | ⭐⭐ |
| Example | Description | Difficulty |
|---|---|---|
| Simple RAG | Vector search with context augmentation | ⭐⭐⭐ |
| Example | Description | Difficulty |
|---|---|---|
| ReAct Agent | Reasoning and acting pattern | ⭐⭐⭐ |
| Example | Description | Difficulty |
|---|---|---|
| LLM-as-Judge | Automated quality evaluation | ⭐⭐⭐ |
| Example | Description | Difficulty |
|---|---|---|
| Rate Limiting | Token bucket rate limiter | ⭐⭐⭐ |
from ai_hub import OpenAIProvider, Message
# Initialize provider
provider = OpenAIProvider(default_model="gpt-4o")
# Simple completion
response = provider.complete([
Message.system("You are a helpful assistant."),
Message.user("What is the capital of France?"),
])
print(response.content)
# With streaming
for chunk in provider.stream([Message.user("Tell me a story")]):
print(chunk.content, end="", flush=True)
# Multi-provider support
from ai_hub import get_provider
openai = get_provider("openai")
anthropic = get_provider("anthropic") # Requires anthropic package- Provider Abstraction - Write once, run on any LLM
- Production-Ready - Retry logic, rate limiting, structured logging
- Type Safety - Full type hints with Pydantic validation
- Testability - Mockable interfaces, comprehensive test coverage
- Observability - Structured JSON logging with metrics
Configuration via environment variables (or .env file):
# Required
OPENAI_API_KEY=sk-...
# Optional
ANTHROPIC_API_KEY=sk-ant-...
AI_HUB_DEFAULT_MODEL=gpt-4o
AI_HUB_LOG_LEVEL=INFO
AI_HUB_MAX_RETRIES=3# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run linting
ruff check .
ruff format .
# Type checking
mypy src/ai_hub
# Pre-commit hooks
pre-commit install
pre-commit run --all-filesThis repository demonstrates:
- Production-grade Python development practices
- Deep understanding of LLM APIs and architectures
- System design for AI applications
- Clean, maintainable, well-documented code
Examples show capability in:
- Building reliable AI-powered features
- Integrating multiple AI providers
- Implementing evaluation and quality control
- Production deployment patterns
Learn from:
- Modern Python packaging (pyproject.toml, ruff)
- Provider abstraction patterns
- Error handling and retry strategies
- Testing LLM applications
MIT License - see LICENSE for details.
Contributions welcome! Please read the contributing guidelines and submit a PR.
Built with modern Python practices and production-grade patterns.