Ms. Potts is an AI-powered nutrition chatbot that provides meal recommendations, dietary advice, and meal logging, personalized based on user profile information. This project follows MLOps best practices with comprehensive monitoring, experiment tracking, and configuration management.
- Retrieval-Augmented Generation (RAG) Pipeline
- Intent Classification
- Personalized Meal Planning
- Meal Logging
- Gemini API Integration
- MLOps Best Practices (Phase 2)
- FastAPI (Backend API)
- Gradio (Frontend UI)
- Sentence-Transformers
- Google Gemini API
- Docker Containerization with Docker Compose
- MLflow Experiment Tracking
- Hydra Configuration Management
- Enhanced Logging and Monitoring
The project has been containerized using separate Dockerfiles for frontend and backend, orchestrated with Docker Compose:
# Build and run with Docker Compose
docker-compose up --build
# Access the frontend at http://localhost:7860
# Access the backend at http://localhost:8080The Dockerfiles include:
- Python 3.10 base image
- All required dependencies
- Proper directory structure
- Environment variable configuration
- Separate entry points for frontend and backend
📊 Monitoring & Debugging Documentation For setup, examples, and troubleshooting guides, click here.
Comprehensive monitoring and debugging tools have been integrated:
# Initialize monitoring
from utils.monitoring import ModelMonitor
monitor = ModelMonitor(metrics_dir="./metrics")
monitor.start_monitoring(interval=5)
# Log model metrics
monitor.log_model_metrics({
"latency_ms": latency_ms,
"tokens_generated": tokens_generated
})
# Initialize debugging
from utils.debugging import DebugTracer, debug_value
tracer = DebugTracer(output_dir="./debug_traces")
# Trace function calls
@tracer.trace_function
def process_query(query):
# Function code
return resultMonitoring metrics include:
- System resources (CPU, memory, disk usage)
- Model performance (latency, token count)
- Application metrics (request processing time, endpoint usage)
For Profiling details and Results, click here.
Profiling tools have been added to identify performance bottlenecks:
# Initialize profilers
from utils.profiling import CodeProfiler, MLProfiler
code_profiler = CodeProfiler(output_dir="./profiling_results")
ml_profiler = MLProfiler(output_dir="./ml_profiling_results")
# Profile functions
@code_profiler.profile_function
def embed_query(query):
# Function code
return embedding
# Profile specific code blocks
with code_profiler.profile_block("similarity_search"):
similarities = calculate_similarities()Profiling results are saved to:
./profiling_results/for Python code profiling./ml_profiling_results/for ML model profiling
For Profiling details and Results, click here.
MLflow has been integrated for experiment tracking:
# Start the MLflow UI
mlflow ui
# Access the UI at http://localhost:5000The application automatically logs:
- Model parameters (embedding model, similarity threshold)
- Performance metrics (retrieval time, response time)
- Query and response data
- Model artifacts
For Logging Details, click here. Rich, structured logging has been implemented:
# Initialize enhanced logger
from utils.enhanced_logging import EnhancedLogger, log_with_context
enhanced_logger = EnhancedLogger(
name="ms_potts",
level="info",
log_dir="./logs",
console_output=True,
file_output=True,
json_output=True,
rich_formatting=True
)
logger = enhanced_logger.get_logger()
# Context-aware logging
log_with_context(
logger,
"info",
"Processing query request",
request_id=request_id,
query=query
)Logs are stored in ./logs/ with detailed context information.
For Configuration Managment, click here. Hydra has been integrated for hierarchical configuration management:
# Run with default (production) configuration
python -m src.ms_potts.main
# Run with development configuration
python -m src.ms_potts.main +mode=development
# Override specific parameters
python -m src.ms_potts.main model.batch_size=64 app.port=9000Configuration files are organized in the conf/ directory:
config.yaml: Main configurationdevelopment.yaml: Development environment overridesproduction.yaml: Production environment overridestesting.yaml: Testing environment overrides
- Python 3.10+
- Docker and Docker Compose (for containerized deployment)
- Clone this repository:
git clone https://github.com/Vedant-1012/ms-potts-mlops.git
cd ms-potts-mlops- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile with your Gemini API Key:
GEMINI_API_KEY=your_api_key_here
- Run the application:
python src/ms_potts/main.py # Backend
python src/ms_potts/interface.py # Frontend- Access the frontend at
http://localhost:7860and the API athttp://localhost:8080
- Build and run with Docker Compose:
docker-compose up --build- Access the frontend at
http://localhost:7860and the API athttp://localhost:8080
├── LICENSE
├── Makefile <- Makefile with commands like `make data` or `make train`
├── README.md <- The top-level README for developers using this project.
├── data
│ ├── external <- Data from third party sources.
│ ├── interim <- Intermediate data that has been transformed.
│ ├── processed <- The final, canonical data sets for modeling.
│ └── raw <- The original, immutable data dump.
│
├── docs <- A default Sphinx project; see sphinx-doc.org for details
│
├── models <- Trained and serialized models, model predictions, or model summaries
│
├── notebooks <- Jupyter notebooks. Naming convention is a number (for ordering),
│ the creator's initials, and a short `-` delimited description, e.g.
│ `1.0-jqp-initial-data-exploration`.
│
├── references <- Data dictionaries, manuals, and all other explanatory materials.
│
├── reports <- Generated analysis as HTML, PDF, LaTeX, etc.
│ └── figures <- Generated graphics and figures to be used in reporting
│
├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g.
│ generated with `pip freeze > requirements.txt`
│
├── setup.py <- makes project pip installable (pip install -e .) so src can be imported
├── src <- Source code for use in this project.
│ ├── __init__.py <- Makes src a Python module
│ │
│ ├── data <- Scripts to download or generate data
│ │ └── make_dataset.py
│ │
│ ├── features <- Scripts to turn raw data into features for modeling
│ │ └── build_features.py
│ │
│ ├── models <- Scripts to train models and then use trained models to make
│ │ │ predictions
│ │ ├── predict_model.py
│ │ └── train_model.py
│ │
│ └── visualization <- Scripts to create exploratory and results oriented visualizations
│ └── visualize.py
│
├── docker-compose.yml <- Docker Compose configuration
├── Dockerfile.backend <- Dockerfile for the backend service
├── Dockerfile.frontend <- Dockerfile for the frontend service
│
├── conf <- Hydra configuration files
│ ├── config.yaml <- Main configuration
│ ├── development.yaml <- Development environment overrides
│ ├── production.yaml <- Production environment overrides
│ └── testing.yaml <- Testing environment overrides
│
├── mlruns <- MLflow experiment tracking data
│
├── logs <- Application logs
│
├── metrics <- Monitoring metrics
│
├── profiling_results <- Code profiling results
│
└── tox.ini <- tox file with settings for running tox; see tox.readthedocs.ioThis project follows these MLOps best practices:
- Containerization: Docker and Docker Compose for consistent deployment
- Monitoring: Tracking system and application metrics
- Debugging: Tracing and value inspection tools
- Profiling: Performance analysis for Python and ML code
- Experiment Tracking: MLflow for tracking parameters, metrics, and artifacts
- Enhanced Logging: Rich, structured logging with context
- Configuration Management: Hydra for hierarchical configuration
MIT License
Project based on the cookiecutter data science project template. #cookiecutterdatascience

