Krishna-11Analyst/LLM-code-deployments
0
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-endpointRequest Format
{
"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)
{
"status": "accepted",
"note": "processing round 1 started"
}Background Process
After returning HTTP 200, the system:
- Generates code using OpenAI GPT-4 (~30-60 seconds)
- Creates/updates GitHub repository (~5-10 seconds)
- Enables GitHub Pages (~10-20 seconds)
- Sends evaluation callback with repo details
๐ ๏ธ Local Development
1. Setup
# 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.txt2. Configure Environment
Create .env file with your credentials:
GITHUB_TOKEN=your_github_token
GITHUB_USERNAME=your_username
OPENAI_API_KEY=your_openai_key
USER_SECRET=your_secret3. Run Server
uvicorn app.main:app --reloadAPI will be available at: http://localhost:8000
4. Test Endpoint
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
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 main3. Configure Secrets
In Space Settings โ Repository secrets, add:
GITHUB_TOKENGITHUB_USERNAMEOPENAI_API_KEYUSER_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
๐ Security Notes
Post-Submission Actions
Within 24 hours of submission, regenerate exposed credentials:
- GitHub Token:
- Visit: https://github.com/settings/tokens
- Delete old token
- Create new token with
repoandworkflowscopes - Update Hugging Face Space secret
- OpenAI Key:
- Visit: https://platform.openai.com/api-keys
- Revoke old key
- Create new key
- 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
