This project provides a secure AI-powered Python code execution environment. Users can input natural language prompts, and the system:
- Uses Hugging Face LLM to generate Python code.
- Executes the code in a secure Docker container.
- Debugs errors & iterates until correct output.
- Explains the generated code.
✅ LLM-Generated Python Code (Using Hugging Face API) ✅ Secure Execution with Docker (Prevents system access) ✅ Automated Debugging & Fixes (Iterates until correct output) ✅ Explains Code & Optimizations ✅ Full-Stack Integration (Fastify backend, Next.js frontend)
ide-docker-py/
│── frontend/ # Next.js frontend (React + Tailwind CSS)
│── python-secure/ # Dockerized Python execution environment
│ ├── Dockerfile # Defines secure Python execution container
│ ├── requirements.txt # Minimal dependencies (if needed)
│ ├── safe_executor.py # Executes AI-generated Python code securely
│── src/ # Fastify backend for LLM & execution
│ ├── server.js # Main backend API (LLM + Docker execution)
│ ├── config.js # Configuration settings
│
│── docker-compose.yml # Containerized setup for easy deployment
│── package.json # Backend dependencies
│── README.md # Project documentation
git clone https://github.com/your-repo/ide-docker-py.git
cd ide-docker-py
pnpm install # Install Fastify & Hugging Face SDK
export HF_TOKEN="your_huggingface_api_key"
cd ide-docker-py
pnpm start
cd frontend
pnpm dev
1️⃣ User provides a natural language prompt (e.g., "Write a Python script to sort a list").
2️⃣ LLM (Hugging Face API) generates Python code.
3️⃣ Code runs inside a secure Docker container.
4️⃣ If errors occur, AI fixes the code & retries execution.
5️⃣ The system returns the output & explains the code.
cd ide-docker-py
sudo docker-compose -f docker-compose.yml up --build
POST /execute
{
"prompt": "Create a Python script to calculate Fibonacci numbers"
}
📤 Response:
{
"success": true,
"iterations": 1,
"code": "def fibonacci(n): ...",
"output": "0 1 1 2 3 5 ...",
"explanation": "This script calculates Fibonacci numbers..."
}
🚀 Feel free to fork this repository and submit pull requests!
This project is open-source under the GNU Public License.