This is an AI-powered debugging assistant I built for Python students as part of the FOSSEE Screening Task. The main idea is to help a student fix their own code by guiding them with hints, not just giving them the answer. It's a live version that connects to Google's Gemini to give real-time feedback.
- Python 3.6+
- A Google Gemini API Key. You can grab one from Google AI Studio.
- Save all the files (
main.py
,ai_debugger.py
,prompt.md
,README.md
) in the same folder. - Create a file named
.env
in that folder to keep your API key safe. Add your key to it like this:GEMINI_API_KEY="YOUR_API_KEY_HERE"
- Open your terminal and
cd
into the project folder. - Install the required libraries:
pip install google-generativeai python-dotenv
- Run the app:
python main.py
- Just follow the prompts to paste your code, pick your skill level, and get feedback from the AI.
Here’s a breakdown of the thinking behind the prompt.md
file, which tells the AI how to act.
I wanted the AI to feel like a friendly, patient, and encouraging tutor. It uses the Socratic method (guiding with questions) because that's a great way to build confidence and encourage critical thinking. Instead of just getting a fix, the student learns how to find the fix themselves.
The strategy is "Hint, Don't Tell." The AI figures out the bug on its own but doesn't just give away the answer. Instead, it uses that knowledge to ask a smart question or give a targeted hint that gets the student looking in the right area. The goal is to let the student have that "aha!" moment of discovery.
The prompt uses a [LEARNER_LEVEL: Beginner/Advanced]
tag so the AI can adjust its hints.
- For Beginners: Hints are very specific, often pointing to a certain line or variable. The focus is on the fundamentals of syntax and how the code is running step-by-step.
- For Advanced Learners: Hints are more high-level. They'll ask about the overall algorithm, edge cases, efficiency (like Big O notation), and other design choices to get them thinking like an experienced developer.