Team Ai
Apppublic

Krishna-11Analyst/LLM-code-deployments

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

LLM Code Deployment System

This is an automated system for building and deploying web applications based on natural language briefs...

๐Ÿš€ LLM Code Deployment System

Production-ready automated web application generator for IIT Madras TDS Project-1.

Live API: https://Krishna-11Analyst-llm-deployment-final.hf.space


โœจ Features

  • โ€”โœ… Correct API Endpoint: /api-endpoint (matches IIT-M specification)
  • โ€”โœ… Multi-Round Support: Handles Round 1 (create) and Round 2+ (update)
  • โ€”โœ… OpenAI GPT-4: Generates complete, working web applications
  • โ€”โœ… Automatic GitHub Integration: Creates repositories and enables Pages
  • โ€”โœ… Duplicate Detection: Uses nonce to prevent reprocessing
  • โ€”โœ… File Attachments: Supports CSV, images, and other data files
  • โ€”โœ… Evaluation Callback: Automatic notification with retry logic
  • โ€”โœ… Background Processing: Non-blocking with immediate HTTP 200 response

๐Ÿ“ก API Usage

Endpoint

POST /api-endpoint

Request Format

json
{
  "email": "student@example.com",
  "secret": "your-secret",
  "task": "unique-task-id",
  "round": 1,
  "nonce": "unique-nonce",
  "brief": "Create a Bootstrap page with weather display",
  "checks": [
    "Repo has MIT license",
    "README.md is professional",
    "Page displays weather data"
  ],
  "evaluation_url": "https://evaluation-server.com/notify",
  "attachments": [
    {
      "name": "data.csv",
      "url": "data:text/csv;base64,..."
    }
  ]
}

Response (Immediate)

json
{
  "status": "accepted",
  "note": "processing round 1 started"
}

Background Process

After returning HTTP 200, the system:

  1. 1.Generates code using OpenAI GPT-4 (~30-60 seconds)
  2. 2.Creates/updates GitHub repository (~5-10 seconds)
  3. 3.Enables GitHub Pages (~10-20 seconds)
  4. 4.Sends evaluation callback with repo details

๐Ÿ› ๏ธ Local Development

1. Setup

bash
# Clone or copy project
cd llm-deployment-final

# Create virtual environment
python -m venv venv

# Activate (Windows)
venv\Scripts\activate

# Activate (Mac/Linux)
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

2. Configure Environment

Create .env file with your credentials:

env
GITHUB_TOKEN=your_github_token
GITHUB_USERNAME=your_username
OPENAI_API_KEY=your_openai_key
USER_SECRET=your_secret

3. Run Server

bash
uvicorn app.main:app --reload

API will be available at: http://localhost:8000

4. Test Endpoint

bash
curl -X POST http://localhost:8000/api-endpoint \
  -H "Content-Type: application/json" \
  -d '{
    "email": "test@example.com",
    "secret": "your_secret",
    "task": "test-001",
    "round": 1,
    "nonce": "test-nonce-001",
    "brief": "Create a simple hello world page",
    "checks": ["Has hello world text"],
    "evaluation_url": "https://httpbin.org/post",
    "attachments": []
  }'

๐Ÿš€ Deployment (Hugging Face Spaces)

1. Create Space

  • โ€”Go to: https://huggingface.co/new-space
  • โ€”Name: llm-deployment-final
  • โ€”SDK: Docker
  • โ€”Hardware: CPU Basic (free tier)

2. Push Code

bash
git init
git add .
git commit -m "Initial deployment"
git remote add space https://huggingface.co/spaces/Krishna-11Analyst/llm-deployment-final
git push space main

3. Configure Secrets

In Space Settings โ†’ Repository secrets, add:

  • โ€”GITHUB_TOKEN
  • โ€”GITHUB_USERNAME
  • โ€”OPENAI_API_KEY
  • โ€”USER_SECRET

4. Wait for Build

Space will build (~5-10 minutes) and show "Running" status when ready.


๐Ÿ“Š Architecture

FastAPI API
    โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ /api-endpoint       โ”‚ โ† Receives JSON POST
โ”‚ - Validates secret  โ”‚
โ”‚ - Returns HTTP 200  โ”‚
โ”‚ - Starts background โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Background Process  โ”‚
โ”‚ 1. OpenAI GPT-4     โ”‚ โ†’ Generate code
โ”‚ 2. GitHub API       โ”‚ โ†’ Create repo
โ”‚ 3. Enable Pages     โ”‚ โ†’ Deploy site
โ”‚ 4. Evaluation POST  โ”‚ โ†’ Notify server
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ง Technology Stack

  • โ€”FastAPI - Web framework
  • โ€”OpenAI GPT-4 - Code generation
  • โ€”PyGithub - GitHub API integration
  • โ€”HTTPX - HTTP client for callbacks
  • โ€”Docker - Containerized deployment
  • โ€”Hugging Face Spaces - Hosting platform

๐Ÿ“‹ Project Structure

llm-deployment-final/
โ”œโ”€โ”€ .env                 # Credentials (DO NOT commit!)
โ”œโ”€โ”€ .gitignore          # Git ignore rules
โ”œโ”€โ”€ .dockerignore       # Docker ignore rules
โ”œโ”€โ”€ Dockerfile          # Docker configuration
โ”œโ”€โ”€ README.md           # This file
โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ”œโ”€โ”€ runtime.txt         # Python version
โ”œโ”€โ”€ test_github.py      # Local testing script
โ””โ”€โ”€ app/
    โ”œโ”€โ”€ __init__.py     # Package init
    โ”œโ”€โ”€ main.py         # FastAPI app & endpoints
    โ”œโ”€โ”€ llm_generator.py # OpenAI code generation
    โ”œโ”€โ”€ github_utils.py # GitHub operations
    โ”œโ”€โ”€ notify.py       # Evaluation callbacks
    โ””โ”€โ”€ signature.py    # (Empty placeholder)

โœ… Submission Information

FieldValue
API Endpointhttps://Krishna-11Analyst-llm-deployment-final.hf.space
Secretstudent_secret_123
GitHub Source Repohttps://github.com/23f2001849/tds-project-1-main
Student Email23f2001849@ds.study.iitm.ac.in

๐Ÿ”’ Security Notes

Post-Submission Actions

Within 24 hours of submission, regenerate exposed credentials:

  1. 1.GitHub Token:
  2. 2.Visit: https://github.com/settings/tokens
  3. 3.Delete old token
  4. 4.Create new token with repo and workflow scopes
  5. 5.Update Hugging Face Space secret
  1. 1.OpenAI Key:
  2. 2.Visit: https://platform.openai.com/api-keys
  3. 3.Revoke old key
  4. 4.Create new key
  5. 5.Update Hugging Face Space secret

๐Ÿ“„ License

MIT License


๐Ÿ‘จโ€๐Ÿ’ป Author

Student ID: 23f2001849 Email: 23f2001849@ds.study.iitm.ac.in Course: IIT Madras - Tools in Data Science - Project 1 Date: October 2025


๐Ÿ™ Acknowledgments

  • โ€”OpenAI for GPT-4 API
  • โ€”GitHub for repository hosting and Pages
  • โ€”Hugging Face for Spaces deployment platform
  • โ€”IIT Madras for the learning opportunity

Built with โค๏ธ for IIT-M TDS Project-1