An intelligent Python-based code debugging agent that analyzes, debugs, and fixes code issues with a Senior Developer persona. Supports multiple free AI providers including Ollama (local) and Hugging Face (free tier).
This project now supports multiple free AI providers:
- Ollama (Recommended) - 100% free, runs locally, no limits, no API keys needed!
- Hugging Face - Free tier available
- OpenAI - Optional paid option
π See docs/FREE_SETUP_GUIDE.md for complete free setup instructions!
π All documentation is in the docs/ folder!
- π Intelligent Code Analysis: Identifies bugs, errors, and potential issues
- π οΈ Automatic Fixes: Provides corrected code with explanations
- π¨βπ» Senior Developer Persona: Expert-level debugging with mentoring approach
- π Code Quality Analysis: Comprehensive code review capabilities
- π― Root Cause Analysis: Explains why issues occur and how to fix them
- π Multiple Free Providers: Works with Ollama, Hugging Face, or OpenAI
.
βββ agent.py # Main agent logic
βββ prompts.py # AI instructions and persona definitions
βββ test_code.py # Broken code examples for testing
βββ quick_debug.py # Quick debugging tool
βββ debug_my_file.py # Example: Debug your own files
βββ example_usage.py # Usage examples
βββ test_setup.py # Setup verification tool
βββ requirements.txt # Python dependencies
βββ docs/ # π All documentation and guides
β βββ README.md # Documentation index
β βββ BEGINNER_GUIDE.md # Complete beginner's guide
β βββ FREE_SETUP_GUIDE.md # Free setup instructions
β βββ NEXT_STEPS.md # What to do after setup
β βββ TEST_WITH_YOUR_CODE.md # How to debug your code
βββ README.md # This file
-
Install dependencies:
pip install -r requirements.txt
-
Install Ollama (completely free, no API key needed):
- Download from: https://ollama.com
- Install it
- Run:
ollama pull llama3.2 - That's it! No API keys needed!
-
Run the debugger:
python agent.py
π For detailed free setup instructions, see docs/FREE_SETUP_GUIDE.md
π All guides: See docs/README.md for complete documentation index
If you prefer Hugging Face:
- Get free API key at: https://huggingface.co/settings/tokens
- Create
.envfile with:HUGGINGFACE_API_KEY=your_key - Change
provider="huggingface"inagent.pymain() function
Run the agent to debug the test code:
python agent.pyfrom agent import CodeDebuggerAgent
# Initialize with Ollama (free, local)
agent = CodeDebuggerAgent(provider="ollama", model="llama3.2")
# Or use Hugging Face (free tier)
# agent = CodeDebuggerAgent(provider="huggingface")
# Or use OpenAI (paid)
# agent = CodeDebuggerAgent(provider="openai", model="gpt-4")
# Debug code
result = agent.debug_code(code_string, error_message="Optional error message")
# Analyze code quality
quality_analysis = agent.analyze_code_quality(code_string)- Provider: Choose
"ollama"(free),"huggingface"(free tier), or"openai"(paid) - Model:
- Ollama:
"llama3.2","codellama","mistral"(all free) - Hugging Face: Various free models
- OpenAI:
"gpt-4","gpt-3.5-turbo"(paid)
- Ollama:
- Temperature: Set to 0.3 for consistent debugging results
The agent provides:
- Analysis: Comprehensive analysis of code issues
- Issues Found: Numbered list of bugs and problems
- Fixed Code: Corrected code with improvements
- Explanation: Detailed explanations of fixes and best practices
- Python 3.8+
- Free Option: Ollama (no API key needed!) - See docs/FREE_SETUP_GUIDE.md
- Alternative: Hugging Face free API key OR OpenAI paid API key
- See
requirements.txtfor dependencies
π All guides and documentation are in the docs/ folder:
- Documentation Index - Start here to find what you need
- Beginner's Guide - Complete guide for beginners
- Free Setup Guide - Set up for free (no API keys!)
- Next Steps - Advanced usage and features
- Testing with Your Own Code - Practical examples
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- π Report bugs
- π‘ Suggest new features
- π§ Submit pull requests
- π Improve documentation
MIT License - see LICENSE file for details.
Created as a portfolio project demonstrating:
- AI/LLM integration
- Python development
- Code analysis and debugging
- Multi-provider architecture
- Comprehensive documentation