This is the Python FastAPI version of the Embula Restaurant Chatbot backend, powered by Mistral AI. It handles:
- Menu queries (filter by vegan/vegetarian/non-veg)
- Table availability & reservations
- Restaurant info (location, contact, opening hours)
- Safe SQL access (restricted tables are blocked)
- Frontend integration ready
- FastAPI: High-performance, easy-to-learn, production-ready framework
- Mistral AI Integration: Uses
mistral-small-latestfor intelligent natural language understanding - Context Awareness: Maintains conversation history per session (in-memory)
- System Personality: Friendly restaurant assistant
- Profanity & SQL Injection Filter: Sanitizes user input using
better-profanityand a custom sanitizer - Database-Safe Queries: Only reads from allowed tables:
food_item,food_item_ingredients,reservations,restaurant_tables,discounts - Frontend Integration Ready: API endpoints can be called via JS, React, Next.js, or any frontend
embula-chatbot-python/
├── src/
│ ├── config/ # Configuration settings
│ ├── models/ # Pydantic models
│ ├── routers/ # API endpoints
│ ├── services/ # Business logic
│ ├── utils/ # Helpers (Memory store)
│ └── main.py # Application entry point
├── .env # Environment variables
├── requirements.txt # Python dependencies
└── README.md # Documentation
1.Prerequisites
- Python 3.9+
- MySQL 8+ (if using a real database)
- Mistral AI API Key
pippackage manager
-
Create Virtual Environment (Recommended):
python -m venv venv # Windows .\venv\Scripts\activate # Mac/Linux source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment:
- Open
.envfile. - Add your Mistral API Key:
MISTRAL_API_KEY=your_actual_key_here
- Open
-
Run the Server:
# Run from the root directory python src/main.py # OR using uvicorn directly uvicorn src.main:app --reload