A Streamlit-based AI coding assistant that generates programming code snippets using a Large Language Model (LLM).
The system allows users to interact through a chat-style interface and automatically generates clean, runnable code with minimal explanations.
🔗 https://code-snippet-generator-27mywk8qvg827jmefv96ce.streamlit.app/
✨ Multi-language code generation (Python, C, C++, Java, etc.)
💬 Chat-style interactive interface
📜 Persistent conversation history
🗑 Delete conversation functionality
🧠 Clean code output with minimal comments
⚡ Fast inference using Groq LLM API
💾 Lightweight JSON-based chat storage
User Input │ ▼ 🖥 Streamlit UI │ ▼ 🧩 Prompt Builder │ ▼ ⚡ Groq LLM API │ ▼ 📄 Generated Code Response │ ▼ 💾 Conversation Storage (JSON)
| Component | Technology |
|---|---|
| 🖥 Frontend UI | Streamlit |
| ⚙ Backend Logic | Python |
| 🤖 LLM Inference | Groq API |
| 🧠 Model Used | LLaMA 3.1 |
| 💾 Storage | JSON-based local storage |
| ☁ Deployment | Streamlit Cloud |
Clone the repository
git clone https://github.com/GithubSohamSaha/code-snippet-generator.git
cd code-snippet-generator
Install dependencies
pip install -r requirements.txt
Create the secrets file
.streamlit/secrets.toml
Add your Groq API key
GROQ_API_KEY="your_api_key_here"
Run the application
streamlit run app.py
Example prompt:
write a python program to check palindrome number
Example output:
def is_palindrome(n): return str(n) == str(n)[::-1]
num = int(input("Enter a number: "))
if is_palindrome(num): print("Palindrome") else: print("Not Palindrome")
The assistant generates clean, executable code along with a short explanation.
This project can be deployed using:
☁ Streamlit Cloud
⚙ Render
🤗 HuggingFace Spaces
Streamlit deployment is the simplest option.
Although the system performs well for many coding tasks, some limitations exist:
⚠ Very large or complex programs may exceed token limits.
⚠ Generated code may require manual debugging for advanced logic.
⚠ Conversation history currently uses local JSON storage, which is not scalable for production.
⚠ API rate limits may apply depending on the Groq usage tier.
⚠ No user authentication or multi-user system is implemented.
⚠ The model may occasionally produce incomplete responses if token limits are reached.
🚀 Integration with database storage (SQLite / PostgreSQL)
🎨 Add syntax highlighting + copy code button
🧠 Automatic programming language detection
🔐 Implement user authentication
⚡ Add real-time streaming responses
🧪 Implement code execution sandbox
👥 Multi-user chat sessions
🔎 Conversation history search
🤖 Support for multiple LLM providers
code-snippet-generator/
├── app.py
├── requirements.txt
├── README.md
├── llm/
│ ├── llm_client.py
│ └── prompt_builder.py
├── storage/
│ └── chat_store.py
└── data/
└── conversations.json
Soham Saha
🎓 B.Tech Computer Science Engineering
📘 Mini Project – CSE 6th Semester
This project is intended for academic and educational purposes.