An AI-powered coding assistant that runs locally and helps you write, edit, and run code through a simple chat interface.
Inspired by ghuntley’s coding agent workshop and enhanced with support for OpenAI APIs or free local Hugging Face models (e.g. Code Llama).
Built entirely in Python with a sleek Gradio web UI.
- 🧑💻 Code Generation & Explanation – ask the agent to write or explain code.
- 📂 File Tools – read, edit, and update local files.
- 🖥️ Command Execution – run shell commands (e.g.
pytest
). - 🔄 Flexible Models
- Use OpenAI GPT-3.5/4 if you have an API key.
- Or run CodeLlama locally for free (no key required).
- 🌐 Web Interface – intuitive chat UI powered by Gradio.
- ⚡ One-Click Run – just
python app.py
and start coding with your AI buddy.
git clone https://github.com/aman-raza/Miniature-Agent-.git
cd Miniature-Agent-
python3 -m venv venv
source venv/bin/activate # (Windows: venv\Scripts\activate)
pip install -r requirements.txt
-
Using OpenAI (recommended for accuracy):
-
Create a .env file in the project root:
OPENAI_API_KEY=sk-xxxx
-
The agent will automatically use GPT-3.5/4.
-
-
Using Hugging Face local model (free):
-
No .env required.
-
The app will download CodeLlama 7B
-
on first run (~13GB).
-
GPU strongly recommended.
-
-
Start the app:
python my_agent.py
http://127.0.0.1:7860
Now you can chat with your coding agent in the browser
-
Writing Code
User: Write a Python function to check if a number is prime. Agent: def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True
-
Running Test
User: Run pytest on the current project. Agent: {"tool": "run_cmd", "input": "pytest --maxfail=1"} Agent: (shows test results)
-
Editing Files
User: Add a function reverse_string(s) to utils.py Agent: ✅ File utils.py updated.
-
Project Structure
coding-agent/ │── my_agent.py # main script (run this) │── requirements.txt # dependencies │── .env # API keys (optional, for OpenAI) │── README.md # this file
- Install pyinstaller and pywebview
pip install pywebview pip install pyinstaller
- Build
.exe
pyinstaller --noconfirm --onefile --windowed main.py
- After building, you’ll find the .exe inside dist/main.exe. Double-click -> results in a true desktop app.
-
⚠️ Notes- Local models require significant RAM/GPU. If limited, prefer OpenAI API.
- Always review code before executing – the agent can run shell commands.
-
📜 License
- MIT License – feel free to fork, modify, and share.
-
🙌 Acknowledgements