mlops-agent / README.md
Abid Ali Awan
feat: Add example datasets and integrate them into the Gradio interface.
e759c43
|
raw
history blame
5.18 kB
metadata
title: MLOps AI Agent
emoji: ♻️
colorFrom: indigo
colorTo: green
sdk: gradio
sdk_version: 6.0.0
app_file: app.py
pinned: false
license: apache-2.0
short_description: Analyse csv, train, deploy, and get endpoint API.
tags:
  - mcp-in-action-track-enterprise

🧠 MLOps Agent: Auto Analysis, Training & Deployment

A fully automated AI powered MLOps agent that you can run in a browser: Upload a CSV → Auto-analyze → Train a model → Deploy → Get example inference code.

This app uses:

  • Gradio (streaming UI)
  • OpenAI Responses API (gpt-5-mini / gpt-5)
  • Remote MCP server for tool calling
  • CSV→Model→Deployment pipeline
  • Streaming chat UX with collapsible technical details
  • Automatic Python & curl example code generation

Link to the LinkedIn post: https://www.linkedin.com/feed/update/urn:li:ugcPost:7399748605563277312/

Link to the YouTube video: https://www.youtube.com/watch?v=dzVgoG1uk0M

🚀 Features

📋 File Size Limits

  • Hard cap: 10MB maximum file size
  • Soft cap: 1.5MB recommended for optimal performance
  • Large file handling: If a file exceeds the soft cap, training will automatically use only the top 10K rows for processing
  • This optimization speeds up the training process and returns model IDs and responses faster

✅ 1. Natural Chat Interface

Chat like a normal assistant — ask questions, discuss data, clarify tasks.

✅ 2. Automatic CSV Analysis

Upload any structured CSV and ask:

“Analyze this dataset”

The agent will produce:

  • Data shape
  • Target detection
  • Basic stats
  • Data quality issues
  • Recommendations

✅ 3. One-Click Model Training

Ask:

“Train a model on this dataset”

The agent will automatically:

  • Train a classifier or regressor
  • Evaluate metrics (Accuracy, F1, ROC-AUC…)
  • Summarize key performance signals

✅ 4. Automated Deployment

Ask:

“Deploy the model”

The MCP backend handles deployment and returns:

  • Deployment status
  • Example Python inference code
  • Example curl usage

✅ 5. Clean, Structured Responses

Every response includes:

Key Summary → Example Usage → Technical Details (collapsible)

  • Main explanation in clear Markdown
  • Python + curl examples outside the collapsible
  • Tools, parameters, and logs inside a <details> block

✅ 6. Full Streaming Output

All assistant messages stream token-by-token for fast UX.

🖥️ UI Overview

Chat + File Upload

  • Drag and drop a CSV
  • Type queries (analysis, training, deployment, follow-ups)
  • Live streaming assistant responses

Collapsible Technical Details

The agent always displays a <details> block containing:

  • Tool names used
  • Parameters passed
  • Training logs
  • Deployment logs
  • Raw JSON (if available)

This keeps the main summary clean while still exposing full transparency.

Clickable Examples

  • Pre-loaded examples for quick testing
  • Triggers analysis, training, deployment, and auto-deployment
  • Uses the included data/heart.csv and data/housing.csv dataset automatically

📦 Installation

Clone the repo:

git clone https://huggingface.co/spaces/MCP-1st-Birthday/mlops-agent
cd mlops-agent

Install dependencies:

pip install -r requirements.txt

Set your environment variable:

export OPENAI_API_KEY="your-key-here"

Run the app:

python app.py

⚙️ Configuration

🔧 Environment Variables

| Variable | Description | | - | | | OPENAI_API_KEY | Your OpenAI key for GPT-5 / GPT-5-mini | | MCP_SERVER_URL | URL of the MCP backend handling analysis/training/deployment |

🧩 Models

You can change:

MODEL = "gpt-5-mini"

to:

MODEL = "gpt-5"

for stronger reasoning on tool outputs.

🧬 Architecture

User → Gradio Chat UI
      → OpenAI Responses API (streaming)
          → MCP Server (tools: analyze, train, deploy)
              → Outputs come back as structured signals
→ Assistant formats them using strict markdown schema
→ Gradio displays stream + collapsible logs

🧪 Example User Flow

1️⃣ Upload CSV

The app generates a public endpoint for the MCP tool to access.

2️⃣ Ask:

Analyze this dataset

3️⃣ Ask:

Train a model

4️⃣ Ask:

Deploy the model

5️⃣ Use Example Code

The assistant outputs example usable code:

Python

import requests
url = "https://YOUR_ENDPOINT"
payload = {...}
print(requests.post(url, json=payload).json())

curl

curl -X POST https://YOUR_ENDPOINT -d '{...}'

📝 System Prompts

The app uses two prompts:

  • General Chat Prompt — for simple conversations
  • Main MLOps Prompt — for analysis, training, evaluation & deployment

Both enforce clean markdown, structured summaries, and technical transparency inside a collapsible block.

🛠️ Tech Stack

  • Python 3.10+
  • Gradio 6.x
  • OpenAI SDK
  • Remote MCP Tool Server (auto-train, evaluate, deploy)
  • Streaming I/O architecture