satyam-k/llm-code-agent
0
llm-code-agent
My Python agent for the LLM code project.
LLM Code Deployment Agent
This project is a FastAPI application designed to automatically receive tasks, generate code using a Large Language Model (Gemini), and deploy the resulting static site to GitHub Pages.
It handles multi-round tasks, allowing for initial creation (Round 1) and subsequent revisions (Round 2+).
Features
- FastAPI Endpoint: A single endpoint (
/api/process-task) to receive JSON task payloads. - Background Processing: Immediately responds
200 OKand performs all work in the background. - LLM Code Generation: Uses the Gemini API to generate
index.html,README.md, andLICENSEfiles. - Multimodal Input: Can process image attachments as context for the LLM.
- GitHub Integration:
- Automatically creates a new public repository (Round 1).
- Clones and updates existing repositories (Round 2+).
- Uses
GitPythonfor local git operations. - Uses
httpxfor direct GitHub API calls (repo creation, Pages activation). - GitHub Pages: Automatically enables or updates the GitHub Pages deployment.
- Robust Error Handling: Includes retries with exponential backoff for all external API calls (LLM, GitHub, Notification).
Deployment (Hugging Face)
This app is designed to be deployed on Hugging Face Spaces.
- Create a new Space on Hugging Face, selecting "Docker" as the SDK.
- Push this code to the Hugging Face git repository.
- Go to the Space's Settings page.
- Add your secrets (
GOOGLE_API_KEY,GITHUB_TOKEN,GITHUB_USER,STUDENT_SECRET) under "Space secrets". - The Space will build the
Dockerfileand start the app automatically. - Your public URL will be
https://[your-space-name].hf.space/api/process-task.
How to Run (For Local Testing)
- Create `.env` file:
- Copy
.env.exampleto.env. - Fill in your
GOOGLE_API_KEY,GITHUB_TOKEN,GITHUB_USER, andSTUDENT_SECRET.
- Build the Docker Container:
docker build -t llm-agent .- Run the Docker Container:
# This maps port 8000 on your laptop to port 7860 inside the container
docker run -p 8000:7860 --env-file .env llm-agent- Test:
- Your server is now running at
http://localhost:8000.
