A free, open-source command-line tool that generates code from natural language prompts using CodeLlama or StarCoder models.
- 🚀 Free & Open-Source - No API keys required
- 💻 Local Execution - Run completely offline
- 🎯 Multiple Languages - Python, JavaScript, Go, Rust, C++, etc.
- ⚡ GPU Acceleration - Faster generation with CUDA
- 💾 Save to File - Direct output to code files
- Python 3.8+
- PyTorch
- Transformers library
- CUDA-capable GPU (optional, but recommended)
# Clone the repository
git clone https://github.com/yourusername/codex-clone.git
cd codex-clone
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Accept HuggingFace terms for CodeLlama
huggingface-cli loginpython codex_cli.py --prompt "Write a function to calculate fibonacci numbers" --language pythonpython codex_cli.py -p "Create a function to validate email addresses" -l javascriptpython codex_cli.py -p "Write a REST API endpoint" -l python -o api.pyUsage: codex_cli.py [OPTIONS]
Options:
-p, --prompt TEXT Natural language description (required)
-l, --language TEXT Programming language [default: python]
--length INTEGER Max tokens to generate [default: 256]
--temperature FLOAT Creativity (0.0-1.0) [default: 0.7]
-o, --output PATH Save to file
--help Show help
The tool supports multiple open-source models:
-
CodeLlama (Recommended)
- Better code quality
- Meta/Facebook trained
- Requires HuggingFace login
-
StarCoder
- No login required
- Good performance
- Faster inference on CPU
Switch models by editing MODEL_NAME in codex_cli.py:
MODEL_NAME = "bigcode/starcoder" # Use StarCoder instead- Use GPU:
CUDA_VISIBLE_DEVICES=0 python codex_cli.py ... - Lower temperature for consistent code:
--temperature 0.3 - Increase length for complex code:
--length 512
- Generated code should be reviewed before use
- Larger models (13B, 34B) require more VRAM
- First run downloads ~7-15GB of model weights
Contributions welcome! Areas for improvement:
- Support for more models
- Fine-tuning for specific languages
- Web UI
- Streaming output
MIT License - See LICENSE file
This tool generates code suggestions. Always review generated code for correctness and security before deploying to production.