An intelligent Python coding assistant powered by Groq API with multiple specialized LLM models. Fix errors, improve code quality, generate new code from prompts, and get plain-English explanations — all in one sleek dark UI.
| Feature | Description | Model Used |
|---|---|---|
| 🔧 Fix Error | Diagnose bugs + get corrected code | llama-3.3-70b-versatile |
| ✨ Improve Code | Optimize, refactor, apply best practices | openai/gpt-oss-20b |
| ⚡ Generate Code | Describe → clarify → get complete code | llama-3.1-8b-instant |
| 📖 Explain Code | Step-by-step plain-English breakdown | openai/gpt-oss-20b |
Python_code_assistant/
│
├── app.py # Entry point — Streamlit UI + page routing
│
├── modules/ # Core feature modules
│ ├── __init__.py
│ ├── groq_client.py # Groq API client + model definitions
│ ├── prompt_engineering.py # All prompts (system + user)
│ ├── error_fixer.py # Fix Error feature logic
│ ├── code_improver.py # Improve Code feature logic
│ ├── code_generator.py # Generate Code (2-stage: clarify → generate)
│ └── code_explainer.py # Explain Code feature logic
│
├── utils/ # Helper utilities
│ ├── __init__.py
│ ├── helpers.py # Session state, history, model info
│ └── formatting.py # Styled UI components (boxes, badges)
│
├── .streamlit/
│ └── secrets.toml # API key (local only, gitignored)
│
├── requirements.txt # Dependencies
├── .gitignore # Git exclusions
└── README.md # This file
User Input
│
▼
app.py (routes to correct page)
│
▼
modules/[feature].py (validates input, calls API)
│
├── modules/prompt_engineering.py (builds prompt)
│
└── modules/groq_client.py (calls Groq API)
│
▼
Groq LLM Response
│
▼
utils/formatting.py (renders UI)
│
▼
User sees output
| Model | Task | Why |
|---|---|---|
llama-3.3-70b-versatile |
Error Fixing | Largest model — best at complex logic debugging |
llama-3.1-8b-instant |
Code Generation | 32K context — handles long generation tasks |
openai/gpt-oss-20b |
Explain + Improve | Fast, instruction-tuned — ideal for clear explanations |
# Option A: Clone from GitHub
git clone https://github.com/jamshaid-develop/ai-python-assistant.git
cd ai_python_assistant
# Option B: Create project folder in PyCharm
# File → New Project → name it Python_code_assistant# In PyCharm terminal (bottom panel):
python -m venv venv
# Activate it:
# Windows:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activatepip install -r requirements.txt- Get your free API key at console.groq.com
- Open
.streamlit/secrets.toml - Replace
your_groq_api_key_herewith your actual key:
GROQ_API_KEY = "gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
⚠️ Never commit secrets.toml to GitHub. It's already in.gitignore.
streamlit run app.pyThe app opens automatically at http://localhost:8501
# Initialize git (if not already)
git init
# Add all files
git add .
# Commit
git commit -m "Initial commit: AI Python Assistant"
# Add your GitHub remote
git remote add origin https://github.com/jamshaid-develop/ai-python-assistant.git
# Push
git branch -M main
git push -u origin main✅ Make sure
.gitignoreis committed — it excludessecrets.tomlautomatically.
- Go to share.streamlit.io
- Click "New app"
- Connect your GitHub account
- Select your repository and set:
- Main file path:
app.py - Branch:
main
- Main file path:
- Click "Advanced settings"
- Under Secrets, add:
GROQ_API_KEY = "gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
- Click "Deploy!"
Your app will be live at https://ai-python-assistant-ihspm34axrboflhdcmbeqc.streamlit.app/ 🎉
| Variable | Description | Where to set |
|---|---|---|
GROQ_API_KEY |
Your Groq API key | .streamlit/secrets.toml (local) or Streamlit Cloud secrets |
- Create
modules/your_feature.py— add your logic function + sample inputs - Add prompts to
modules/prompt_engineering.py - Add a new page case in
app.py's radio nav options - Add a history entry with
add_to_history()
Edit modules/groq_client.py — update the MODEL_* constants at the top of the file.
streamlit>=1.32.0 # UI framework
groq>=0.5.0 # Groq API client
No heavy ML libraries — runs on Streamlit Cloud free tier.
MIT License — free to use, modify, and distribute.
Built with ❤️ using Python, Streamlit, and Groq API