🤖 BTL Python AI Coder
Personalized AI-powered Python code completion extension for VS Code

GitHub Copilot alternative with personalization - learns your coding style and adapts suggestions to match your preferences!
✨ Tính năng chính
🎯 Personalized AI Suggestions
- Học phong cách code của bạn: Tự động phát hiện indent, quotes, naming conventions
- Càng dùng càng thông minh: Học từ mỗi completion bạn accept
- Privacy-focused: User ID anonymous (SHA-256 hash), không lưu code
- GDPR compliant: Xóa data bất cứ lúc nào
⚡ Fast & Smart
- Groq Cloud API: Powered by llama-3.3-70b-versatile
- Sub-second response: Nhanh, chính xác
- Cloud-hosted: 24/7 availability trên Render.com
- Smart postprocessing: Tự động format, align indentation
🛠️ Developer Friendly
- Inline completion: Gợi ý ngay khi gõ code
- Configurable: Nhiều settings để customize
- Profile dashboard: Xem metrics coding style của bạn
- Feedback tracking: Tự động cải thiện từ usage
🚀 Cài đặt
Từ VS Code Marketplace (Khuyến nghị)
- Mở VS Code
- Vào Extensions (
Ctrl+Shift+X)
- Tìm "BTL Python AI Coder"
- Click Install
Từ Source Code
# Clone repository
git clone https://github.com/Sagitoaz/BTL_Python.git
cd BTL_Python
# Cài dependencies
npm install
# Compile TypeScript
npm run compile
# Press F5 trong VS Code để test
📖 Cách sử dụng
Sử dụng cơ bản
- Mở file Python bất kỳ
- Bắt đầu gõ code
- Đợi 1-2 giây để AI gợi ý (ghost text màu xám)
- Nhấn Tab để accept suggestion
- Nhấn Esc để dismiss
Extension sẽ tự động học style code của bạn!
Xem Coding Profile
Cmd/Ctrl + Shift + P
- Gõ:
BTL: View My Coding Profile
- Xem metrics: indent size, quote preference, naming convention, type hints usage, etc.
Xóa Data (GDPR)
Cmd/Ctrl + Shift + P
- Gõ:
BTL: Clear My Coding Profile
- Confirm deletion
⚙️ Settings
Mở VS Code Settings (Cmd/Ctrl + ,) và tìm "BTL":
| Setting |
Default |
Mô tả |
btl.serverUrl |
Cloud server |
URL backend API |
btl.apiKey |
5conmeo |
API key authentication |
btl.timeoutMs |
15000 |
Timeout request (ms) |
btl.enablePersonalization |
true |
Bật/tắt personalization |
btl.sendFeedback |
true |
Gửi feedback để cải thiện |
btl.enableStreaming |
false |
Streaming mode (thử nghiệm) |
🎯 Personalization hoạt động thế nào?
Style Detection
Extension phát hiện:
- Indentation: Tabs hay spaces? 2, 4, hay 8 spaces?
- Quotes: Single
' hay double "?
- Naming:
snake_case hay camelCase?
- Type hints: Có dùng type annotations không?
- Docstrings: Format docstring như thế nào?
- Line length: Độ dài dòng tối đa ưa thích
Incremental Learning
Mỗi khi accept completion:
- Code được analyze để tìm patterns
- Profile được update (weighted averaging: 30% mới, 70% cũ)
- Lần sau AI sẽ gợi ý theo style đã học
Privacy
- User ID: SHA-256 hash của machine ID (anonymous)
- Storage: Profile lưu trên server dạng JSON
- Data stored: CHỈ metrics, KHÔNG lưu code thật
- GDPR: Có thể xóa data bất cứ lúc nào
🏗️ Kiến trúc
┌─────────────────────┐
│ VS Code Extension │ (TypeScript)
│ Inline Provider │
└──────────┬──────────┘
│ HTTPS + X-User-ID header
▼
┌─────────────────────┐
│ FastAPI Backend │ (Python)
│ User Profiling │
│ on Render.com │
└──────────┬──────────┘
│ API Call
▼
┌─────────────────────┐
│ Groq Cloud API │ (LLM)
│ llama-3.3-70b-versatile │
└─────────────────────┘
Backend Endpoints:
POST /complete - Lấy code completion (với X-User-ID)
POST /feedback/completion - Gửi feedback accept/reject
GET /feedback/profile - Xem user profile
DELETE /feedback/profile - Xóa user data
GET /health - Health check
CLI Tester
echo "def add(a, b):\n " | python tools/cli.py --server https://btl-python-r9kz.onrender.com --api-key 5conmeo
Stress Test
python tools/stress.py --server https://btl-python-r9kz.onrender.com --api-key 5conmeo --requests 100 --concurrency 10
🛠️ Development
Chạy Local Backend
cd server
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 9000 --reload
Compile Extension
npm install
npm run compile
# hoặc watch mode:
npm run watch
Test Extension
Press F5 trong VS Code để launch Extension Development Host
Run Tests
# Backend tests
cd server
pytest
# Frontend compile test
npm run compile
📝 Changelog
Xem CHANGELOG.md để biết lịch sử phiên bản.
v1.0.0 (Latest):
- ✨ Personalization system
- ✨ User profiling với style detection
- ✨ Feedback tracking
- ✨ Profile management commands
- 🔒 Privacy-focused với GDPR compliance
📄 License
MIT License - xem LICENSE file.
🐛 Known Issues
- Dedent keywords:
elif/else/except cần manual cursor positioning (VS Code API limitation)
- Cold start: Request đầu tiên có thể chậm do Render.com free tier
- Streaming mode: Experimental, có thể không ổn định
🤝 Contributing
Contributions welcome!
- Fork repo
- Create feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'feat: add amazing feature'
- Push:
git push origin feature/amazing-feature
- Open Pull Request
🙏 Acknowledgments
- Groq - Fast LLM inference
- VS Code - Extension API
- FastAPI - Backend framework
- Render.com - Free hosting
Made with ❤️ by Sagito | Powered by Groq 🚀
Test Cases:
- ✅ Simple functions
- ✅ Fibonacci recursion
- ✅ Class methods
- ✅ List comprehensions
- ✅ Try-except blocks
- ✅ Nested functions
- ✅ Dictionary operations
🔧 Configuration
Edit .vscode/settings.json:
{
"btl.serverUrl": "https://btl-python-r9kz.onrender.com",
"btl.apiKey": "5conmeo",
"btl.timeoutMs": 15000
}
📊 Example Usage
def fibonacci(n):
if n <= 1:
return n
█ # cursor here
AI Suggestion
else:
return fibonacci(n-1) + fibonacci(n-2)
🛠️ Tech Stack
Frontend (Extension)
- TypeScript
- VSCode Extension API
- Inline Completion Provider
Backend (Server)
- Python 3.11+
- FastAPI
- Uvicorn (with uvloop)
- Groq Cloud API
- Black & autopep8 (formatting)
Infrastructure
- Render.com (hosting)
- GitHub Actions (CI/CD)
- JSONL (telemetry storage)
📈 Monitoring & Telemetry
Health Check
curl https://btl-python-r9kz.onrender.com/health
View Stats (requires API key)
curl -H "Authorization: Bearer 5conmeo" \
https://btl-python-r9kz.onrender.com/admin/telemetry/stats
Run Monitoring Suite
python tools/monitor_dashboard.py
🎓 How It Works
- User types code in VSCode
- Extension captures context (prefix + suffix)
- Sends request to FastAPI server
- Server calls Groq LLM with enhanced prompt
- Postprocessing pipeline:
- Strip markdown fences
- Align indentation
- Remove overlaps
- Auto-format with black/autopep8
- Normalize whitespace (fallback)
- Return completion to VSCode
- Record telemetry for improvement
🏆 Achievements
- 🎯 100% success rate (vs ~70% before)
- 🚫 0% markdown issues (vs 80% before)
- ✅ Zero syntax errors (normalization fallback)
- ⚡ Sub-second latency (optimized pipeline)
- 📊 Full telemetry system (dataset collection)
- 🧪 Automated testing (integration + unit tests)
- ☁️ Cloud deployment (24/7 availability)
🤝 Contributing
# 1. Fork & clone
git clone https://github.com/Sagitoaz/BTL_Python.git
# 2. Create branch
git checkout -b feature/your-feature
# 3. Make changes & test
npm run compile
# Press F5 to test
# 4. Commit & push
git commit -m "feat: your feature"
git push origin feature/your-feature
# 5. Create Pull Request
📝 License
MIT License - See LICENSE file for details
🙏 Acknowledgments
- Groq Cloud - Ultra-fast LLM inference
- Render.com - Reliable hosting platform
- VSCode API - Powerful extension framework
- FastAPI - Modern Python web framework
📞 Support
🎉 Status
✅ PROJECT COMPLETE - PRODUCTION READY
Server: https://btl-python-r9kz.onrender.com
Status: 🟢 Online
Last Updated: November 2, 2025
Made with ❤️ by Sagito
Happy coding! 🚀✨