📦 First Stable Release v0.0.12
Date: 2025-04-05
Project: OpenAI Compatible Chatbot API Template
🌟 Overview
This marks the first stable release of the OpenAI-compatible chatbot API template, a FastAPI-based framework for building chatbot APIs with visualization capabilities. It includes core functionality for production-ready deployments, robust mock implementations for development, and seamless integration with MongoDB and Gradio.
🔍 Key Features
-
OpenAI-Compatible API
- Full support for
/v1/chat/completions
endpoints (GET, POST, GET by ID, and message history). - Dynamic storage of chat completions, messages, and Plotly visualizations.
- API key authentication via HMAC signatures (
Authorization: Bearer sk-<username>-<token>
).
- Full support for
-
Mock Implementation
- Ready-to-use mock responses for all endpoints (enable with
DATABASE_TYPE=embedded
). Just clone and run! Enjoy a fully functional chatbot API without needing a database. - In-memory storage for local development with
embedded
database type.
- Ready-to-use mock responses for all endpoints (enable with
-
Database Support
- Production-ready MongoDB integration (via
motor
driver). - Embedded MongoDB for local testing (
mongomock-motor
).
- Production-ready MongoDB integration (via
-
Visualization
- Gradio-powered UI for interactive chatbot demos with Plotly figure rendering.
- Static file hosting for web app manifests and custom styles.
-
Infrastructure
- Docker-compose setup for MongoDB.
- Environment variable configuration for flexible deployments.
🛠️ Notable Improvements
Features
- Enhanced chat completion service with improved error handling and logging.
- Conversation API (
/conversation
) for managing chat histories. - Gradio UI enhancements (authentication, fixed port, modular app separation). FastAPI and Gradio integration for a seamless user experience.
Code Quality
- Codebase reformatted with
ruff
(line length 145). - Removed deprecated code and unused variables.
- Modularized repository and factory patterns for scalability.
📚 Documentation
- Detailed README with:
- Installation instructions (Docker, dependencies, MongoDB setup).
- API usage examples (curl, Gradio).
- Contribution guidelines (branching strategy, linting, PR process).
- Open issues and roadmap tracking.
⚠️ Known Limitations
- This system is a template and does not include all OpenAI API features.
Just focus on the input and output of the API endpoints, such as chat completions and messages.
For example, it does not use themodel
parameter in chat completions, as it is not required for basic functionality.
When using this template, you need to use model in llm or agenticAI packages
UV usage On Local Machine instead of pip
- UV Documentation: https://astral.sh/uv
- Linux/MacOS :
curl -Ls https://astral.sh/uv/install.sh | sh
- Windows :
irm https://astral.sh/uv/install.ps1 | iex
- Rust/Cargo : ```cargo install --git https://github.com/astral-sh/uv uv``
🚀 Installation
# Clone the repository
git clone https://github.com/lokumai/openai-openapi-template.git
cd openai-openapi-template
# Install dependencies
uv sync
# Start MongoDB
docker compose -f docker/mongodb-docker-compose.yaml up -d
# Run the API
./run.sh
Environment Variables
# Configure database (default: mongodb)
DB_DATABASE_TYPE=mongodb
# API key secret (generate with ./scripts/api_key_generator.sh)
API_SECRET_KEY=my-secret
📈 Roadmap
- Implement missing DELETE chat endpoints.
- Add Langchain integration for advanced chatbot capabilities.
- Enhance Gradio UI with message editing and plot customization.
- Expand test suite and CI/CD pipelines.
- User and role management features.(e.g., user authentication, role-based access control).
🙌 Acknowledgments
Special thanks to contributors for testing, feedback, and code improvements.
GitHub: https://github.com/lokumai/openai-openapi-template
Hugging Face: https://huggingface.co/spaces/lokumai/openai-openapi-template
🎉 Congratulations! You’re ready to build and deploy your own OpenAI-compatible chatbot. Let’s code responsibly!