Skip to content

shaungehring/rapidai

Repository files navigation

RapidAI πŸš€

PyPI version Python 3.10+ License: MIT

Production-ready Python framework for building AI applications fast

RapidAI is designed for one thing: getting from idea to deployed AI application in under an hour. When your boss asks you to POC the latest AI tool, this is the framework you reach for.

Vision

A web framework that bridges the gap between Flask's simplicity and Django's batteries-included approach, but optimized specifically for modern AI development. Think of it as "the Rails of AI apps" - convention over configuration, but for LLM-powered applications.

✨ Features

  • πŸ€– Zero-config LLM integration - Built-in support for Anthropic Claude, OpenAI, Cohere with unified interface
  • πŸ“‘ Streaming by default - SSE/WebSocket streaming built into routes, not bolted on
  • πŸ”„ Background jobs - Async task processing with automatic retry and job tracking
  • πŸ“Š Built-in monitoring - Token usage, cost tracking, and metrics dashboard
  • 🎨 UI components - Pre-built chat interfaces with customizable themes
  • πŸ“š RAG system - Document loading, embeddings, vector DB integration for retrieval
  • πŸ“ Prompt management - Version control and templating for prompts with Jinja2
  • πŸ’Ύ Smart caching - Semantic caching using embedding similarity
  • πŸ§ͺ Testing utilities - TestClient, MockLLM, MockMemory for easy testing
  • ⚑ CLI tool - Project templates, dev server, deployment, and more

πŸš€ Quick Start

Simple Chat Endpoint

from rapidai import App, LLM

app = App()
llm = LLM("claude-3-haiku-20240307")

@app.route("/chat", methods=["POST"])
async def chat(message: str):
    response = await llm.complete(message)
    return {"response": response}

if __name__ == "__main__":
    app.run()

With Streaming

from rapidai import App, LLM

app = App()
llm = LLM("claude-3-haiku-20240307")

@app.route("/chat", methods=["POST"])
async def chat(message: str):
    async for chunk in llm.stream(message):
        yield chunk

if __name__ == "__main__":
    app.run()

With Background Jobs

from rapidai import App, background

app = App()

@background(max_retries=3)
async def process_document(doc_id: str):
    # Long-running task runs in background
    await analyze_document(doc_id)

@app.route("/process", methods=["POST"])
async def start_processing(doc_id: str):
    job = await process_document(doc_id)
    return {"job_id": job.id, "status": job.status}

With Monitoring

from rapidai import App, LLM, monitor

app = App()
llm = LLM("claude-3-haiku-20240307")

@app.route("/chat", methods=["POST"])
@monitor()  # Automatically tracks tokens and costs
async def chat(message: str):
    return await llm.complete(message)

@app.route("/metrics")
async def metrics():
    return app.get_metrics_html()  # Built-in dashboard

πŸ“¦ Installation

pip install rapidai-framework

Optional Dependencies

Install with specific features:

# Anthropic Claude support
pip install "rapidai-framework[anthropic]"

# OpenAI support
pip install "rapidai-framework[openai]"

# RAG (document loading, embeddings, vector DB)
pip install "rapidai-framework[rag]"

# Redis (for caching and memory)
pip install "rapidai-framework[redis]"

# Everything
pip install "rapidai-framework[all]"

# Development tools
pip install "rapidai-framework[dev]"

πŸ“‹ What's Included

Core Framework

  • βœ… App class - Fast async web server with routing
  • βœ… LLM clients - Anthropic Claude, OpenAI, Cohere with unified interface
  • βœ… Streaming - Built-in SSE support for real-time responses
  • βœ… Memory - Conversation history (in-memory and Redis)
  • βœ… Caching - Semantic caching with embedding similarity
  • βœ… Config - Environment-based configuration with Pydantic

Advanced Features

  • βœ… Background jobs - @background decorator with retry logic and job tracking
  • βœ… Monitoring - @monitor decorator with token/cost tracking and HTML dashboard
  • βœ… RAG system - Document loading (PDF, DOCX, TXT, HTML, MD), embeddings, vector DB
  • βœ… Prompt management - Template-based prompts with Jinja2 and versioning
  • βœ… UI components - Pre-built chat interfaces with themes and customization
  • βœ… Testing utilities - TestClient, MockLLM, MockMemory for easy testing

Developer Tools

  • βœ… CLI tool - rapidai new, rapidai dev, rapidai deploy, rapidai test
  • βœ… Project templates - Chatbot, RAG, Agent, API templates
  • βœ… Type hints - Full type coverage for IDE support
  • βœ… Documentation - Complete guides and API references at https://shaungehring.github.io/rapidai/

Status

Version: 1.0.0 - Production Ready πŸŽ‰

See CHANGELOG.md for release notes.

πŸ’‘ Use Cases

Perfect for building:

  • πŸ€– Chat applications - Customer support bots, AI assistants
  • πŸ“š RAG systems - Document Q&A, knowledge bases
  • πŸ”§ Internal tools - AI-powered dashboards and workflows
  • πŸ“Š Data processing - Background jobs for document analysis
  • 🌐 AI APIs - REST endpoints with LLM integration
  • 🎯 Rapid prototypes - POCs and MVPs in under an hour

🎯 Philosophy

  1. Convention over configuration - Sensible defaults, minimal boilerplate
  2. Provider agnostic - Swap OpenAI for Anthropic with one line
  3. Async-first - Built on modern async/await patterns
  4. Type-safe - Full type hints for excellent IDE support
  5. Batteries included - Everything you need, nothing you don't
  6. Production ready - Monitoring, testing, deployment from day one

πŸ“š Documentation

Complete documentation available at https://shaungehring.github.io/rapidai/

πŸ› οΈ CLI Tool

RapidAI includes a powerful CLI for project scaffolding and management:

# Create a new project from template
rapidai new my-chatbot --template chatbot

# Start development server with hot reload
rapidai dev

# Run tests
rapidai test

# Deploy to cloud platforms
rapidai deploy --platform vercel

# Generate documentation
rapidai docs

Available templates:

  • chatbot - Simple chat application
  • rag - RAG system with document Q&A
  • agent - AI agent with tools
  • api - REST API with LLM endpoints

πŸ‘¨β€πŸ’» Development

# Clone the repository
git clone https://github.com/shaungehring/rapidai.git
cd rapidai

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

# Run tests with coverage
pytest --cov=rapidai tests/

# Type check
mypy rapidai

# Lint and format
ruff check rapidai
ruff format rapidai

🀝 Community & Support

πŸš€ Publishing

RapidAI is available on PyPI. To publish a new version:

# Test on TestPyPI first
./scripts/publish.sh test

# Publish to production PyPI
./scripts/publish.sh prod

See PUBLISHING.md for complete publishing guide.

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Contributing

We welcome contributions! Whether it's:

  • πŸ› Bug fixes
  • ✨ New features
  • πŸ“š Documentation improvements
  • πŸ§ͺ Test coverage
  • πŸ’‘ Ideas and suggestions

See CONTRIBUTING.md for guidelines on how to contribute.

⭐ Show Your Support

If you find RapidAI helpful, please consider:

  • ⭐ Starring the GitHub repository
  • πŸ“’ Sharing with your network
  • πŸ› Reporting issues you encounter
  • πŸ’‘ Suggesting new features

Built with ❀️ for AI engineers who move fast

Version: 1.0.0 | Status: Production Ready πŸŽ‰

About

RapidAI is designed for one thing: getting from idea to deployed AI application in under an hour.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors