AI-powered Python debugging assistant โ ChatGPT for Python errors
Project description
PyDebugAI ๐
AI-powered Python debugging assistant โ like ChatGPT, but exclusively for Python errors. Installable via
pip. Runs in your terminal and in VSCode.
Features
| Feature | Description |
|---|---|
| ๐ AST Static Analysis | Catches errors before running โ undefined names, division by zero, type mismatches |
| ๐ค Rule Engine | 60+ hand-crafted rules for instant, deterministic fixes |
| ๐ง ML Classifier | TF-IDF + Random Forest classifies error types with high confidence |
| ๐ Levenshtein Fixer | Detects typos in variable/function names and suggests corrections |
| ๐ CodeBERT | Deep semantic code understanding via HuggingFace transformers |
| ๐ Self-Learning | SQLite + RLHF-lite โ improves from every upvote/downvote |
| ๐งฉ VSCode Extension | Red squiggles, hover hints, quick-fix menu, sidebar chat panel |
| ๐ป CLI Runner | pydebugai run file.py โ run and debug from your terminal |
Quick Start
1. Install via pip
pip install pydebugai
Or install from source (this repo):
cd c:\new-model-ai
pip install -e .
2. Run the CLI
# Analyze a Python file
pydebugai run my_script.py
# Interactive chat mode (paste code or errors)
pydebugai chat
# Start the local API server (required for VSCode extension)
pydebugai serve
# Show self-learning statistics
pydebugai stats
3. Install the VSCode Extension
# Install from .vsix (after packaging)
code --install-extension vscode-extension/pydebugai-0.1.0.vsix
Or in VSCode: Extensions โ Install from VSIX...
Then start the server in your terminal:
pydebugai serve
The extension will:
- Show red squiggles on error lines
- Display hover hints with fix suggestions
- Offer ๐ก Fix with PyDebugAI in the quick-fix menu
- Open the sidebar panel with full AI analysis
AI Algorithms
User Code
โ
โโโบ AST Analyzer (static, instant)
โ โโ SyntaxError, IndentationError, undefined names,
โ division by zero, comparison style warnings
โ
โโโบ Code Executor (subprocess, safe)
โ โโ Captures stdout / stderr / exit code
โ
โโโบ Error Parser (regex traceback parser)
โ โโ Extracts: exception type, message, file, line, col
โ
โโโบ Rule Engine (60+ rules, deterministic)
โ โโ Pattern-match โ instant fix suggestion
โ
โโโบ ML Classifier (TF-IDF + Random Forest)
โ โโ Classifies error type โ boosts rule confidence
โ
โโโบ Levenshtein Fixer (edit distance)
โ โโ "Did you mean 'print'?" for NameError/AttributeError
โ
โโโบ CodeBERT (HuggingFace, optional)
โ โโ Semantic embeddings โ cosine similarity retrieval
โ
โโโบ Orchestrator โ Merge, Deduplicate, Rank by confidence
โโโบ Top-10 suggestions โ CLI / VSCode / API
Self-Learning Loop (RLHF-lite)
User gives thumbs-up / thumbs-down on suggestion
โ Stored in SQLite (pydebugai/data/feedback.db)
โ Positive samples accumulate
โ Every 25 positive samples โ auto-retrain ML classifier
โ Model improves over time per user
CLI Examples
# Run and auto-debug a buggy file
pydebugai run tests/samples/buggy_sample.py
# Get output as JSON (pipe to other tools)
pydebugai run my_script.py --json
# Static analysis only (don't execute)
pydebugai run my_script.py --no-exec
# Deep analysis with CodeBERT (slower)
pydebugai run my_script.py --deep
# Interactive REPL
pydebugai chat
>>> x = 10 / 0
# (press Enter twice)
# โ AI prints fix suggestions
API (for VSCode extension & custom integrations)
Start server: pydebugai serve (default: http://localhost:7432)
# Analyze code
curl -X POST http://localhost:7432/analyze \
-H "Content-Type: application/json" \
-d '{"code": "print(udefined)"}'
# Record feedback
curl -X POST http://localhost:7432/feedback \
-H "Content-Type: application/json" \
-d '{"interaction_id": 1, "selected_idx": 0, "feedback": 1}'
# Health check
curl http://localhost:7432/status
# Stats
curl http://localhost:7432/stats
Requirements
Minimal (fast startup, no ML)
click, rich, fastapi, uvicorn, pydantic
Full AI features
scikit-learn # ML classifier
transformers # CodeBERT
torch # PyTorch backend
python-Levenshtein # fast edit distance
Install all:
pip install -r requirements.txt
Running Tests
cd c:\new-model-ai
python tests/test_error_parser.py
python tests/test_ast_analyzer.py
python tests/test_rule_engine.py
VSCode Extension Settings
| Setting | Default | Description |
|---|---|---|
pydebugai.serverPort |
7432 |
Local server port |
pydebugai.analyzeOnSave |
true |
Auto-analyze on save |
pydebugai.enableExecution |
false |
Run code during analysis |
pydebugai.pythonPath |
python |
Python interpreter path |
License
MIT ยฉ PyDebugAI Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydebugai-0.1.0.tar.gz.
File metadata
- Download URL: pydebugai-0.1.0.tar.gz
- Upload date:
- Size: 685.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18c1236e612a258205135baaa4ee33fc81c5159711a040c1b4e76196c3e7f4d3
|
|
| MD5 |
0ce32d3954999748c6fee87694d97d5b
|
|
| BLAKE2b-256 |
37550d18f23882bbce0f259956616c46a42ce9c8386ea516f72d64cee77bc3d1
|
File details
Details for the file pydebugai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydebugai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 700.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f266f451a472c399ac880317fdad7f1eee6185165820e4ef3e83aa3cd381def1
|
|
| MD5 |
1c64a138992442c2ecc5eb7638781c63
|
|
| BLAKE2b-256 |
126fd47b822ea834478fccf56bd19adaa231f3300cd5c8c9f5db1e02a34eb3b9
|